1.Easy
Which complexity class grows fastest for large n?
- AO(n log n)
- BO(n²)
- CO(n³)
- DO(2ⁿ)
2.Easy
Which of these grows slowest as n becomes large?
- AO(log n)
- BO(n log n)
- CO(n²)
- DO(n)
3.Easy
An algorithm's running time is O(n). What is this growth called?
- AConstant
- BQuadratic
- CLogarithmic
- DLinear
4.Medium
What does amortised analysis measure?
- AThe cost of an algorithm on the best input
- BThe average cost per operation over a worst-case sequence of operations
- CThe expected cost over random inputs
- DThe cost of the single most expensive operation anywhere in the sequence
5.Medium
What is the time complexity of: for i = 1 to n: (j = 1; while j < n: j = j × 2)?
- AO(n)
- BO(n²)
- CO(log n)
- DO(n log n)
6.Medium
Quicksort always uses the first element as pivot. On which input does it show its worst-case behaviour?
- AAn array in random order
- BAn array that is already sorted
- CAn array of length 2
- DAn array whose elements are all different
7.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX is in NP, and a known NP-complete problem reduces to X in polynomial time
- BX reduces to a problem in P, and X is in NP
- CX has no polynomial algorithm, and X is decidable
- DX is in P, and X reduces to SAT
8.Hard
What does the recurrence T(n) = 2T(n/2) + n log n solve to?
- AΘ(n)
- BΘ(n log² n)
- CΘ(n²)
- DΘ(n log n)
Answer key
- 1. D · O(2ⁿ)
- 2. A · O(log n)
- 3. D · Linear
- 4. B · The average cost per operation over a worst-case sequence of operations
- 5. D · O(n log n)
- 6. B · An array that is already sorted
- 7. A · X is in NP, and a known NP-complete problem reduces to X in polynomial time
- 8. B · Θ(n log² n)
Full step-by-step solutions: practise this topic on examproblems.com.