1.Easy
An O(n) algorithm takes 3 seconds for n = 1 million. About how long does it take for n = 2 million?
- A9 seconds
- B6 seconds
- C12 seconds
- D3 seconds
2.Easy
What is the time complexity of binary search on a sorted array?
- AO(1)
- BO(n)
- CO(n log n)
- DO(log n)
3.Easy
Which design strategy does merge sort use?
- ADivide and conquer
- BDynamic programming
- CGreedy choice
- DBrute force
4.Medium
With coins of 1, 3 and 4 and an amount of 6, how many coins does the greedy "largest coin first" method use, compared to the optimum?
- AGreedy uses 2 coins; the optimum is 2
- BGreedy uses 3 coins; the optimum is 2
- CGreedy uses 4 coins; the optimum is 3
- DGreedy uses 3 coins; the optimum is 3
5.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- ANo, because n³ is smaller than n² for large n
- BNo, because Big O must always state the exact growth rate of the function
- CYes, but only if n is smaller than 100
- DYes, because Big O is an upper bound and n² grows no faster than n³
6.Medium
In the activity selection problem, which greedy rule always gives a maximum number of non-overlapping activities?
- APick the shortest activity first
- BPick the activity with the fewest overlaps first, then repeat with the compatible ones
- CPick the activity that starts earliest
- DPick the activity that finishes earliest, then repeat with the compatible ones
7.Hard
Karatsuba multiplication satisfies T(n) = 3T(n/2) + O(n). What does this solve to?
- AΘ(n log n)
- BΘ(n²)
- CΘ(n3)
- DΘ(nlog₂ 3), about n1.585
8.Hard
The 0/1 knapsack problem solved with dynamic programming takes O(nW) time. Why is this called pseudo-polynomial?
- ABecause it only works for W = 0
- BW is a number, so the time is exponential in the number of bits used to write W
- CBecause the algorithm is randomised and its running time varies with each input
- DBecause n is always small
Answer key
- 1. B · 6 seconds
- 2. D · O(log n)
- 3. A · Divide and conquer
- 4. B · Greedy uses 3 coins; the optimum is 2
- 5. D · Yes, because Big O is an upper bound and n² grows no faster than n³
- 6. D · Pick the activity that finishes earliest, then repeat with the compatible ones
- 7. D · Θ(nlog₂ 3), about n1.585
- 8. B · W is a number, so the time is exponential in the number of bits used to write W
Full step-by-step solutions: practise this topic on examproblems.com.