1.Easy
What is the base case of a recursive function?
- AA case that is answered directly without making another recursive call
- BThe call that uses the most memory
- CThe case with the largest input, which is handled before any recursive calls
- DThe first line of the function
2.Easy
Which sorting algorithm chooses a pivot and partitions the array into smaller and larger elements?
- AMerge sort
- BQuicksort
- CInsertion sort
- DBubble sort
3.Easy
A problem is usually called tractable if:
- AIt can be solved in polynomial time
- BIt has no solution
- CIt can be solved in constant time
- DIt can only be solved by trying every possibility
4.Medium
What does amortised analysis measure?
- AThe expected cost over random inputs
- BThe cost of an algorithm on the best input
- CThe average cost per operation over a worst-case sequence of operations
- DThe cost of the single most expensive operation anywhere in the sequence
5.Medium
With coins of 1, 3 and 4 and an amount of 6, how many coins does the greedy "largest coin first" method use, compared to the optimum?
- AGreedy uses 3 coins; the optimum is 2
- BGreedy uses 3 coins; the optimum is 3
- CGreedy uses 4 coins; the optimum is 3
- DGreedy uses 2 coins; the optimum is 2
6.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- ANo, because n³ is smaller than n² for large n
- BYes, because Big O is an upper bound and n² grows no faster than n³
- CNo, because Big O must always state the exact growth rate of the function
- DYes, but only if n is smaller than 100
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, the lower bound applies to the worst case over all inputs, not to every input
- CYes, but only for arrays shorter than 100
- DNo, because insertion sort is not a comparison sort
8.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX is in P, and X reduces to SAT
- BX reduces to a problem in P, and X is in NP
- CX has no polynomial algorithm, and X is decidable
- DX is in NP, and a known NP-complete problem reduces to X in polynomial time
Answer key
- 1. A · A case that is answered directly without making another recursive call
- 2. B · Quicksort
- 3. A · It can be solved in polynomial time
- 4. C · The average cost per operation over a worst-case sequence of operations
- 5. A · Greedy uses 3 coins; the optimum is 2
- 6. B · Yes, because Big O is an upper bound and n² grows no faster than n³
- 7. B · No, the lower bound applies to the worst case over all inputs, not to every input
- 8. D · X is in NP, and a known NP-complete problem reduces to X in polynomial time
Full step-by-step solutions: practise this topic on examproblems.com.