1.Easy
Which of these running times is polynomial?
- AO(n!)
- BO(nⁿ)
- CO(2ⁿ)
- DO(n³)
2.Easy
Which complexity class grows fastest for large n?
- AO(n log n)
- BO(n³)
- CO(2ⁿ)
- DO(n²)
3.Easy
An algorithm with two nested loops, each running n times, typically has which complexity?
- AO(n²)
- BO(2n)
- CO(n)
- DO(log n)
4.Medium
A greedy algorithm:
- AAlways gives the optimal solution
- BUses only recursion
- CMakes the locally best choice at each step
- DTries every possible solution
5.Medium
Which sorting algorithm is stable?
- AQuicksort (typical in-place version)
- BSelection sort (typical version)
- CHeap sort
- DMerge sort
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(n log n)
- BO(log n)
- CO(n²)
- DO(n)
7.Hard
The halting problem shows that:
- ASome programs run faster on faster computers, so halting depends on hardware
- BLoops should be avoided
- CNo algorithm can decide for every program and input whether it halts
- DEvery program eventually halts
8.Hard
How does the Bellman–Ford algorithm detect a negative-weight cycle reachable from the source?
- AAfter V − 1 rounds, it checks whether any edge can still be relaxed
- BIt counts the cycles with depth-first search
- CIt runs Dijkstra's algorithm twice and compares the two distance results
- DIt checks whether any edge has a negative weight
Answer key
- 1. D · O(n³)
- 2. C · O(2ⁿ)
- 3. A · O(n²)
- 4. C · Makes the locally best choice at each step
- 5. D · Merge sort
- 6. A · O(n log n)
- 7. C · No algorithm can decide for every program and input whether it halts
- 8. A · After V − 1 rounds, it checks whether any edge can still be relaxed
Full step-by-step solutions: practise this topic on examproblems.com.