1.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²)
2.Easy
An O(n²) algorithm takes 1 second for n = 1000. About how long does it take for n = 2000?
- A4 seconds
- B2 seconds
- C8 seconds
- D1 second
3.Easy
What is the base case of a recursive function?
- AThe call that uses the most memory
- BThe first line of the function
- CA case that is answered directly without making another recursive call
- DThe case with the largest input, which is handled before any recursive calls
4.Medium
Which sorting algorithm is stable?
- AMerge sort
- BQuicksort (typical in-place version)
- CHeap sort
- DSelection sort (typical version)
5.Medium
What does the recurrence T(n) = T(n − 1) + O(1) solve to?
- AO(n)
- BO(log n)
- CO(n²)
- DO(2ⁿ)
6.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(n)
- BO(n log n)
- CO(log n)
- DO(n²)
7.Hard
Which definition of the class NP is correct?
- AProblems that cannot be solved in polynomial time
- BDecision problems whose yes-answers can be verified in polynomial time given a certificate
- CProblems that are not polynomial
- DProblems that no algorithm can solve
8.Hard
How do n! and 2ⁿ compare for large n?
- An! is O(n²)
- B2ⁿ grows faster than n!
- CThey grow at the same rate
- Dn! grows faster than 2ⁿ
Answer key
- 1. B · O(n)
- 2. A · 4 seconds
- 3. C · A case that is answered directly without making another recursive call
- 4. A · Merge sort
- 5. A · O(n)
- 6. A · O(n)
- 7. B · Decision problems whose yes-answers can be verified in polynomial time given a certificate
- 8. D · n! grows faster than 2ⁿ
Full step-by-step solutions: practise this topic on examproblems.com.