1.Easy
What does the average-case running time describe?
- AThe time on the most common computer
- BThe expected time over a given distribution of inputs of size n
- CThe time for an input of average length
- DThe middle value between the best-case and worst-case running times
2.Easy
What is the time complexity of depth-first search on a graph stored as adjacency lists?
- AO(V × E)
- BO(E log V)
- CO(V + E)
- DO(V²)
3.Easy
An O(n) algorithm takes 3 seconds for n = 1 million. About how long does it take for n = 2 million?
- A3 seconds
- B6 seconds
- C9 seconds
- D12 seconds
4.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(n²)
- BO(log n)
- CO(n log n)
- DO(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
You sort an array of n elements once and then answer k membership queries with binary search. What is the total cost?
- AO(k n log n)
- BO(n + k)
- CO(nk)
- DO(n log n + k 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?
- AYes, the lower bound is therefore wrong
- BNo, because insertion sort is not a comparison sort
- CYes, but only for arrays shorter than 100
- DNo, the lower bound applies to the worst case over all inputs, not to every input
8.Hard
What did the Cook–Levin theorem establish?
- AP is not equal to NP
- BThe Boolean satisfiability problem (SAT) is NP-complete
- CThe halting problem is undecidable
- DEvery NP problem can be solved in exponential time
Answer key
- 1. B · The expected time over a given distribution of inputs of size n
- 2. C · O(V + E)
- 3. B · 6 seconds
- 4. D · O(n)
- 5. A · O(V × E)
- 6. D · O(n log n + k log n)
- 7. D · No, the lower bound applies to the worst case over all inputs, not to every input
- 8. B · The Boolean satisfiability problem (SAT) is NP-complete
Full step-by-step solutions: practise this topic on examproblems.com.