1.Easy
What is the worst-case time complexity of merge sort?
- AO(n)
- BO(log n)
- CO(n²)
- DO(n log n)
2.Easy
What is the time complexity of linear search in an unsorted array of n elements (worst case)?
- AO(log n)
- BO(n)
- CO(1)
- DO(n²)
3.Easy
What is log₂ 1024?
- A12
- B512
- C10
- D32
4.Medium
Dynamic programming is useful when a problem has:
- ANo subproblems at all, so it can be solved in one step
- BOnly random inputs
- COverlapping subproblems and optimal substructure
- DA single loop
5.Medium
What does the recurrence T(n) = 2T(n − 1) + O(1) solve to?
- AO(n)
- BO(2ⁿ)
- CO(n²)
- DO(n log n)
6.Medium
What does the recurrence T(n) = T(n − 1) + O(n) solve to?
- AO(n)
- BO(n²)
- CO(2ⁿ)
- DO(n log n)
7.Hard
Taking both endpoints of every edge in a maximal matching gives a vertex cover. How good is this cover?
- AAt most twice the size of a minimum vertex cover
- BAlways a minimum vertex cover
- CAt most log n times the minimum
- DOf unknown quality compared to the optimum
8.Hard
How does the Bellman–Ford algorithm detect a negative-weight cycle reachable from the source?
- AIt counts the cycles with depth-first search
- BAfter V − 1 rounds, it checks whether any edge can still be relaxed
- CIt checks whether any edge has a negative weight
- DIt runs Dijkstra's algorithm twice and compares the two distance results
Answer key
- 1. D · O(n log n)
- 2. B · O(n)
- 3. C · 10
- 4. C · Overlapping subproblems and optimal substructure
- 5. B · O(2ⁿ)
- 6. B · O(n²)
- 7. A · At most twice the size of a minimum vertex cover
- 8. B · After V − 1 rounds, it checks whether any edge can still be relaxed
Full step-by-step solutions: practise this topic on examproblems.com.