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
- B3 seconds
- C12 seconds
- D6 seconds
2.Easy
What is a brute-force algorithm?
- AOne that guesses an answer at random
- BOne that tries all possible candidate solutions
- COne that runs on many processors
- DOne that always uses recursion
3.Easy
What does it mean if an operation runs in O(1) time?
- AIt can only be run once
- BIt processes exactly one element per second of running time
- CIt always takes exactly one second
- DIts running time does not grow with the input size
4.Medium
What does amortised analysis measure?
- AThe average cost per operation over a worst-case sequence of operations
- BThe cost of an algorithm on the best input
- CThe cost of the single most expensive operation anywhere in the sequence
- DThe expected cost over random inputs
5.Medium
What does the Floyd–Warshall algorithm compute, and how fast?
- AA topological order in O(V²)
- BA minimum spanning tree in O(E log V)
- CShortest paths from one source vertex to all others in O(V + E)
- DShortest paths between all pairs of vertices in O(V³)
6.Medium
What does it mean that a problem has optimal substructure?
- AThe problem can be solved in constant time
- BAn optimal solution can be built from optimal solutions of its subproblems
- CEvery subproblem has the same size
- DThe problem has exactly one optimal solution, which every subproblem shares
7.Hard
Strassen's algorithm multiplies matrices using 7 instead of 8 recursive multiplications of half-size blocks. What is its running time?
- AΘ(n³)
- BΘ(n² log n)
- CΘ(nlog₂ 7), about n2.81
- DΘ(n2)
8.Hard
Which statement about selecting the k-th smallest element of an unsorted array is correct?
- AQuickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
- BQuickselect runs in O(log n) worst case, because it recurses on only one side of the pivot
- CSelection is only possible in O(n²)
- DSelection always needs Ω(n log n) because it requires sorting
Answer key
- 1. D · 6 seconds
- 2. B · One that tries all possible candidate solutions
- 3. D · Its running time does not grow with the input size
- 4. A · The average cost per operation over a worst-case sequence of operations
- 5. D · Shortest paths between all pairs of vertices in O(V³)
- 6. B · An optimal solution can be built from optimal solutions of its subproblems
- 7. C · Θ(nlog₂ 7), about n2.81
- 8. A · Quickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
Full step-by-step solutions: practise this topic on examproblems.com.