1.Easy
What is a brute-force algorithm?
- AOne that tries all possible candidate solutions
- BOne that runs on many processors
- COne that always uses recursion
- DOne that guesses an answer at random
2.Easy
What does it mean if an operation runs in O(1) time?
- AIt always takes exactly one second
- BIt can only be run once
- CIt processes exactly one element per second of running time
- DIts running time does not grow with the input size
3.Easy
An algorithm's running time is O(n). What is this growth called?
- ALogarithmic
- BLinear
- CQuadratic
- DConstant
4.Medium
What does the recurrence T(n) = T(n/2) + O(1) solve to?
- AO(log n)
- BO(1)
- CO(n log n)
- DO(n)
5.Medium
A greedy algorithm:
- AMakes the locally best choice at each step
- BUses only recursion
- CAlways gives the optimal solution
- DTries every possible solution
6.Medium
What does amortised analysis measure?
- AThe expected cost over random inputs
- BThe average cost per operation over a worst-case sequence of operations
- CThe cost of an algorithm on the best input
- DThe cost of the single most expensive operation anywhere in the sequence
7.Hard
What is the time complexity of: for i = 1 to n: for (j = i; j ≤ n; j = j + i) do O(1) work?
- AO(n²)
- BO(n)
- CO(n √n)
- DO(n log n)
8.Hard
A problem is NP-complete if it is:
- AIn NP and every NP problem reduces to it in polynomial time
- BSolvable in polynomial time
- CImpossible to solve
- DOutside NP but harder than all NP problems, such as the halting problem
Answer key
- 1. A · One that tries all possible candidate solutions
- 2. D · Its running time does not grow with the input size
- 3. B · Linear
- 4. A · O(log n)
- 5. A · Makes the locally best choice at each step
- 6. B · The average cost per operation over a worst-case sequence of operations
- 7. D · O(n log n)
- 8. A · In NP and every NP problem reduces to it in polynomial time
Full step-by-step solutions: practise this topic on examproblems.com.