1.Easy
What are the three steps of a divide-and-conquer algorithm?
- ARead, compute, write
- BSort, search, return
- CGuess, check, repeat
- DDivide, conquer, combine
2.Easy
What does it mean if an operation runs in O(1) time?
- AIt processes exactly one element per second of running time
- BIts running time does not grow with the input size
- CIt always takes exactly one second
- DIt can only be run once
3.Easy
What is the running time of counting sort for n integers in the range 0 to k?
- AO(n + k)
- BO(k log n)
- CO(n²)
- DO(n log n)
4.Medium
Why is the base of a logarithm usually left out in Big O, as in O(log n)?
- AThe base only matters for small n
- BAll logarithms in computer science have base 10, so it is implied
- CLogarithms with different bases differ only by a constant factor
- DLogarithms are always rounded to integers
5.Medium
A function runs one loop of n iterations and then, separately, another loop of n iterations. What is its time complexity?
- AO(n²)
- BO(n)
- CO(log n)
- DO(2ⁿ)
6.Medium
Dynamic programming is useful when a problem has:
- AOverlapping subproblems and optimal substructure
- BNo subproblems at all, so it can be solved in one step
- COnly random inputs
- DA single loop
7.Hard
Which bound is correct for log(n!)?
- AΘ(n²)
- BΘ(log n)
- CΘ(n)
- DΘ(n log n)
8.Hard
The Held–Karp dynamic programming algorithm solves the travelling salesman problem exactly. What is its running time for n cities?
- AO(2n²)
- BO(n!)
- CO(n³)
- DO(n² 2ⁿ)
Answer key
- 1. D · Divide, conquer, combine
- 2. B · Its running time does not grow with the input size
- 3. A · O(n + k)
- 4. C · Logarithms with different bases differ only by a constant factor
- 5. B · O(n)
- 6. A · Overlapping subproblems and optimal substructure
- 7. D · Θ(n log n)
- 8. D · O(n² 2ⁿ)
Full step-by-step solutions: practise this topic on examproblems.com.