1.Easy
What is the worst-case time complexity of insertion sort?
- AO(log n)
- BO(n)
- CO(n log n)
- DO(n²)
2.Easy
What is the base case of a recursive function?
- AThe first line of the function
- BThe call that uses the most memory
- CThe case with the largest input, which is handled before any recursive calls
- DA case that is answered directly without making another recursive call
3.Easy
Space complexity measures:
- AThe disk space of the program file once it is compiled
- BThe physical size of the computer
- CThe number of lines of code
- DThe amount of memory an algorithm needs as input grows
4.Medium
What does the recurrence T(n) = 2T(n − 1) + O(1) solve to?
- AO(2ⁿ)
- BO(n log n)
- CO(n)
- DO(n²)
5.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 whose elements are all different
- CAn array of length 2
- DAn array that is already sorted
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(n log n)
- BO(n)
- CO(log n)
- DO(n²)
7.Hard
Using the master theorem, T(n) = 8T(n/2) + O(n²) solves to:
- AΘ(n³)
- BΘ(n² log n)
- CΘ(n²)
- DΘ(n log n)
8.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
Answer key
- 1. D · O(n²)
- 2. D · A case that is answered directly without making another recursive call
- 3. D · The amount of memory an algorithm needs as input grows
- 4. A · O(2ⁿ)
- 5. D · An array that is already sorted
- 6. A · O(n log n)
- 7. A · Θ(n³)
- 8. D · No, the lower bound applies to the worst case over all inputs, not to every input
Full step-by-step solutions: practise this topic on examproblems.com.