1.Easy
What is the running time of counting sort for n integers in the range 0 to k?
- AO(n log n)
- BO(n²)
- CO(n + k)
- DO(k log n)
2.Easy
What is a brute-force algorithm?
- AOne that guesses an answer at random
- BOne that always uses recursion
- COne that runs on many processors
- DOne that tries all possible candidate solutions
3.Easy
What is the base case of a recursive function?
- AThe case with the largest input, which is handled before any recursive calls
- BA case that is answered directly without making another recursive call
- CThe first line of the function
- DThe call that uses the most memory
4.Medium
What is the time complexity of the standard dynamic programming algorithm for the longest common subsequence of strings of lengths m and n?
- AO(2m+n)
- BO(mn)
- CO(mn log n)
- DO(m + n)
5.Medium
What is the time complexity of the Bellman–Ford algorithm on a graph with V vertices and E edges?
- AO(V × E)
- BO(V + E)
- CO(E log V)
- DO(V³ × E)
6.Medium
What is the time complexity of computing the n-th Fibonacci number with a bottom-up table?
- AO(n)
- BO(n²)
- CO(2ⁿ)
- DO(log n)
7.Hard
Karatsuba multiplication satisfies T(n) = 3T(n/2) + O(n). What does this solve to?
- AΘ(n3)
- BΘ(nlog₂ 3), about n1.585
- CΘ(n log n)
- DΘ(n²)
8.Hard
How is the travelling salesman problem classified?
- AIt is in P because Dijkstra's algorithm solves it by visiting every city once
- BThe decision version is NP-complete and the optimisation version is NP-hard
- CIt is undecidable
- DThe decision version is in P but the optimisation version is NP-complete
Answer key
- 1. C · O(n + k)
- 2. D · One that tries all possible candidate solutions
- 3. B · A case that is answered directly without making another recursive call
- 4. B · O(mn)
- 5. A · O(V × E)
- 6. A · O(n)
- 7. B · Θ(nlog₂ 3), about n1.585
- 8. B · The decision version is NP-complete and the optimisation version is NP-hard
Full step-by-step solutions: practise this topic on examproblems.com.