1.Easy
Space complexity measures:
- AThe number of lines of code
- BThe disk space of the program file once it is compiled
- CThe amount of memory an algorithm needs as input grows
- DThe physical size of the computer
2.Easy
What is the Big O of 3n² + 5n + 2?
- AO(n³)
- BO(n²)
- CO(3n²)
- DO(5n)
3.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- ABubble sort
- BHeap sort
- CQuicksort
- DMerge sort
4.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(log n)
- BO(n)
- CO(n²)
- DO(n log n)
5.Medium
Which statement about a recursive function without a reachable base case is correct?
- AIt keeps calling itself until the call stack overflows
- BThe compiler always turns it into a loop that ends safely
- CIt returns 0 automatically
- DIt runs in O(1) time
6.Medium
About how many comparisons does binary search need in the worst case on a sorted array of 1,000,000 elements?
- AAbout 20
- BAbout 1,000
- CAbout 100
- DAbout 500,000
7.Hard
Which of these satisfiability problems is known to be solvable in polynomial time?
- AGeneral SAT on formulas in conjunctive normal form
- B3-SAT, where each clause has exactly three literals
- CCircuit satisfiability
- D2-SAT, where each clause has at most two literals
8.Hard
The halting problem shows that:
- AEvery program eventually halts
- BNo algorithm can decide for every program and input whether it halts
- CSome programs run faster on faster computers, so halting depends on hardware
- DLoops should be avoided
Answer key
- 1. C · The amount of memory an algorithm needs as input grows
- 2. B · O(n²)
- 3. A · Bubble sort
- 4. B · O(n)
- 5. A · It keeps calling itself until the call stack overflows
- 6. A · About 20
- 7. D · 2-SAT, where each clause has at most two literals
- 8. B · No algorithm can decide for every program and input whether it halts
Full step-by-step solutions: practise this topic on examproblems.com.