1.Easy
Which of these running times is polynomial?
- AO(n³)
- BO(nⁿ)
- CO(2ⁿ)
- DO(n!)
2.Easy
What is the best-case time complexity of insertion sort, on an already sorted array?
- AO(1)
- BO(n)
- CO(n log n)
- DO(n²)
3.Easy
What is an algorithm?
- AA programming language designed for writing mathematical formulas
- BA finite sequence of well-defined steps that solves a problem
- CAny computer program that has a graphical interface
- DA data structure that stores numbers
4.Medium
Why does dynamic programming give no real speed-up for merge sort?
- ADynamic programming only works on graph problems, not on arrays
- BMerge sort is already O(n)
- CMerge sort has no recursive structure
- DIts subproblems do not overlap, so there is nothing to reuse
5.Medium
What does the recurrence T(n) = T(n − 1) + O(n) solve to?
- AO(2ⁿ)
- BO(n)
- CO(n log n)
- DO(n²)
6.Medium
A greedy algorithm:
- AMakes the locally best choice at each step
- BAlways gives the optimal solution
- CTries every possible solution
- DUses only recursion
7.Hard
Insertion sort runs in O(n) on sorted input. Does this contradict the Ω(n log n) lower bound for comparison sorting?
- ANo, because insertion sort is not a comparison sort
- BYes, but only for arrays shorter than 100
- CYes, the lower bound is therefore wrong
- DNo, the lower bound applies to the worst case over all inputs, not to every input
8.Hard
Which technique gives an expected O(n log n) running time for quicksort on any input?
- AUsing recursion only on the left side
- BChoosing the pivot uniformly at random
- CSorting the input before running quicksort
- DAlways choosing the first element
Answer key
- 1. A · O(n³)
- 2. B · O(n)
- 3. B · A finite sequence of well-defined steps that solves a problem
- 4. D · Its subproblems do not overlap, so there is nothing to reuse
- 5. D · O(n²)
- 6. A · Makes the locally best choice at each step
- 7. D · No, the lower bound applies to the worst case over all inputs, not to every input
- 8. B · Choosing the pivot uniformly at random
Full step-by-step solutions: practise this topic on examproblems.com.