1.Easy
What is the base case of a recursive function?
- AA case that is answered directly without making another recursive call
- BThe first line of the function
- CThe call that uses the most memory
- DThe case with the largest input, which is handled before any recursive calls
2.Easy
Which notation describes an upper bound on growth?
- ABig Omega
- BBig Theta
- CLittle omega
- DBig O
3.Easy
A problem is usually called tractable if:
- AIt can only be solved by trying every possibility
- BIt can be solved in polynomial time
- CIt can be solved in constant time
- DIt has no solution
4.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(n log n)
- BO(n)
- CO(log n)
- DO(n²)
5.Medium
In a sorted array, you look for two elements that sum to a target by moving one pointer from each end inwards. What is the time complexity?
- AO(n log n)
- BO(log n)
- CO(n)
- DO(n²)
6.Medium
What is the amortised time complexity of appending to a dynamic array that doubles its capacity when full?
- AO(log n)
- BO(n²)
- CO(n)
- DO(1)
7.Hard
Why is the average lookup in a hash table O(1) but the worst case O(n)?
- AArrays have O(n) access
- BHash functions are slow
- CMany keys may collide into the same bucket
- DKeys must be sorted first
8.Hard
Which algorithm finds a minimum spanning tree by repeatedly adding the cheapest edge that does not form a cycle?
- AKruskal's algorithm
- BFloyd–Warshall
- CDijkstra's algorithm
- DPrim's algorithm starting from one node
Answer key
- 1. A · A case that is answered directly without making another recursive call
- 2. D · Big O
- 3. B · It can be solved in polynomial time
- 4. B · O(n)
- 5. C · O(n)
- 6. D · O(1)
- 7. C · Many keys may collide into the same bucket
- 8. A · Kruskal's algorithm
Full step-by-step solutions: practise this topic on examproblems.com.