1.Easy
What are the three steps of a divide-and-conquer algorithm?
- ASort, search, return
- BDivide, conquer, combine
- CRead, compute, write
- DGuess, check, repeat
2.Easy
Which notation describes an upper bound on growth?
- ABig O
- BBig Theta
- CLittle omega
- DBig Omega
3.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- ABubble sort
- BHeap sort
- CMerge sort
- DQuicksort
4.Medium
What is the worst-case time complexity of quicksort?
- AO(n)
- BO(log n)
- CO(n²)
- DO(n log n)
5.Medium
What does the recurrence T(n) = T(n/2) + O(1) solve to?
- AO(n log n)
- BO(log n)
- CO(1)
- DO(n)
6.Medium
Why do many library sorting routines switch to insertion sort for very small subarrays?
- AInsertion sort is O(n log n) in the worst case
- BInsertion sort has little overhead and is fast on small or nearly sorted inputs
- CInsertion sort uses less memory than any other sorting algorithm on large inputs
- DRecursive algorithms cannot handle arrays below 10 elements
7.Hard
The 0/1 knapsack problem solved with dynamic programming takes O(nW) time. Why is this called pseudo-polynomial?
- AW is a number, so the time is exponential in the number of bits used to write W
- BBecause n is always small
- CBecause the algorithm is randomised and its running time varies with each input
- DBecause it only works for W = 0
8.Hard
Using the master theorem, T(n) = 8T(n/2) + O(n²) solves to:
- AΘ(n² log n)
- BΘ(n log n)
- CΘ(n³)
- DΘ(n²)
Answer key
- 1. B · Divide, conquer, combine
- 2. A · Big O
- 3. A · Bubble sort
- 4. C · O(n²)
- 5. B · O(log n)
- 6. B · Insertion sort has little overhead and is fast on small or nearly sorted inputs
- 7. A · W is a number, so the time is exponential in the number of bits used to write W
- 8. C · Θ(n³)
Full step-by-step solutions: practise this topic on examproblems.com.