1.Easy
What is the worst-case time complexity of insertion sort?
- AO(log n)
- BO(n²)
- CO(n)
- DO(n log n)
2.Easy
What is a brute-force algorithm?
- AOne that always uses recursion
- BOne that runs on many processors
- COne that tries all possible candidate solutions
- DOne that guesses an answer at random
3.Easy
An O(n²) algorithm takes 1 second for n = 1000. About how long does it take for n = 2000?
- A2 seconds
- B4 seconds
- C8 seconds
- D1 second
4.Medium
Which statement about a recursive function without a reachable base case is correct?
- AIt keeps calling itself until the call stack overflows
- BIt returns 0 automatically
- CIt runs in O(1) time
- DThe compiler always turns it into a loop that ends safely
5.Medium
Why does dynamic programming give no real speed-up for merge sort?
- AIts subproblems do not overlap, so there is nothing to reuse
- BDynamic programming only works on graph problems, not on arrays
- CMerge sort has no recursive structure
- DMerge sort is already O(n)
6.Medium
Which algorithm finds the shortest paths from one source in a graph with non-negative edge weights?
- ADijkstra's algorithm
- BKruskal's algorithm
- CDepth-first search
- DBellman–Ford is required in all cases
7.Hard
Is 22n in O(2ⁿ)?
- ANo, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
- BNo, because 22n grows more slowly than 2ⁿ
- CYes, because both are exponential
- DYes, because constant factors in the exponent are always ignored in Big O
8.Hard
How do n! and 2ⁿ compare for large n?
- An! is O(n²)
- B2ⁿ grows faster than n!
- Cn! grows faster than 2ⁿ
- DThey grow at the same rate
Answer key
- 1. B · O(n²)
- 2. C · One that tries all possible candidate solutions
- 3. B · 4 seconds
- 4. A · It keeps calling itself until the call stack overflows
- 5. A · Its subproblems do not overlap, so there is nothing to reuse
- 6. A · Dijkstra's algorithm
- 7. A · No, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
- 8. C · n! grows faster than 2ⁿ
Full step-by-step solutions: practise this topic on examproblems.com.