1.Easy
An algorithm with two nested loops, each running n times, typically has which complexity?
- AO(log n)
- BO(n²)
- CO(n)
- DO(2n)
2.Easy
Which sorting algorithm chooses a pivot and partitions the array into smaller and larger elements?
- ABubble sort
- BQuicksort
- CInsertion sort
- DMerge sort
3.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
4.Medium
What does the recurrence T(n) = T(n/2) + O(1) solve to?
- AO(1)
- BO(n)
- CO(log n)
- DO(n log n)
5.Medium
The lower bound for comparison-based sorting in the worst case is:
- AΩ(log n)
- BΩ(n²)
- CΩ(n log n)
- DΩ(n)
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(n²)
- BO(log n)
- CO(n 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 no algorithm can solve
- DProblems that are not polynomial
8.Hard
Using the master theorem, T(n) = 8T(n/2) + O(n²) solves to:
- AΘ(n²)
- BΘ(n log n)
- CΘ(n² log n)
- DΘ(n³)
Answer key
- 1. B · O(n²)
- 2. B · Quicksort
- 3. D · A case that is answered directly without making another recursive call
- 4. C · O(log n)
- 5. C · Ω(n log n)
- 6. C · O(n log n)
- 7. B · Decision problems whose yes-answers can be verified in polynomial time given a certificate
- 8. D · Θ(n³)
Full step-by-step solutions: practise this topic on examproblems.com.