1.Easy
An algorithm with two nested loops, each running n times, typically has which complexity?
- AO(2n)
- BO(n²)
- CO(n)
- DO(log n)
2.Easy
Which of these running times is polynomial?
- AO(2ⁿ)
- BO(nⁿ)
- CO(n³)
- DO(n!)
3.Easy
What is an algorithm?
- AA finite sequence of well-defined steps that solves a problem
- BAny computer program that has a graphical interface
- CA programming language designed for writing mathematical formulas
- DA data structure that stores numbers
4.Medium
Breadth-first search on an unweighted graph finds:
- AThe minimum spanning tree
- BShortest paths in graphs that contain negative edge weights
- CA topological order in all graphs
- DShortest paths in number of edges from the start node
5.Medium
What does the recurrence T(n) = T(n − 1) + O(n) solve to?
- AO(n)
- BO(2ⁿ)
- CO(n log n)
- DO(n²)
6.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(n)
- BO(n log n)
- CO(n²)
- DO(log n)
7.Hard
Insertion sort runs in O(n) on sorted input. Does this contradict the Ω(n log n) lower bound for comparison sorting?
- ANo, the lower bound applies to the worst case over all inputs, not to every input
- BNo, because insertion sort is not a comparison sort
- CYes, the lower bound is therefore wrong
- DYes, but only for arrays shorter than 100
8.Hard
Which statement about little-o notation is correct?
- An = o(n²), but n is not o(n)
- Bn² = o(n)
- C2n = o(n), because 2n grows slowly
- Dn = o(n), since every function is little-o of itself
Answer key
- 1. B · O(n²)
- 2. C · O(n³)
- 3. A · A finite sequence of well-defined steps that solves a problem
- 4. D · Shortest paths in number of edges from the start node
- 5. D · O(n²)
- 6. A · O(n)
- 7. A · No, the lower bound applies to the worst case over all inputs, not to every input
- 8. A · n = o(n²), but n is not o(n)
Full step-by-step solutions: practise this topic on examproblems.com.