1.Easy
A loop starts with i = 1 and doubles i each iteration until i > n. How many iterations does it run?
- AAbout n
- BAbout log₂ n
- CAbout n²
- DAbout n / 2
2.Easy
Which complexity class grows fastest for large n?
- AO(2ⁿ)
- BO(n³)
- CO(n²)
- DO(n log n)
3.Easy
An O(n²) algorithm takes 1 second for n = 1000. About how long does it take for n = 2000?
- A8 seconds
- B2 seconds
- C1 second
- D4 seconds
4.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(n²)
- BO(log n)
- CO(n log n)
- DO(n)
5.Medium
Breadth-first search on an unweighted graph finds:
- AThe minimum spanning tree
- BShortest paths in graphs that contain negative edge weights
- CA topological order in all graphs
- DShortest paths in number of edges from the start node
6.Medium
In the activity selection problem, which greedy rule always gives a maximum number of non-overlapping activities?
- APick the activity that finishes earliest, then repeat with the compatible ones
- BPick the activity that starts earliest
- CPick the activity with the fewest overlaps first, then repeat with the compatible ones
- DPick the shortest activity first
7.Hard
Which algorithm finds a minimum spanning tree by repeatedly adding the cheapest edge that does not form a cycle?
- AKruskal's algorithm
- BDijkstra's algorithm
- CFloyd–Warshall
- DPrim's algorithm starting from one node
8.Hard
Taking both endpoints of every edge in a maximal matching gives a vertex cover. How good is this cover?
- AOf unknown quality compared to the optimum
- BAlways a minimum vertex cover
- CAt most twice the size of a minimum vertex cover
- DAt most log n times the minimum
Answer key
- 1. B · About log₂ n
- 2. A · O(2ⁿ)
- 3. D · 4 seconds
- 4. C · O(n log n)
- 5. D · Shortest paths in number of edges from the start node
- 6. A · Pick the activity that finishes earliest, then repeat with the compatible ones
- 7. A · Kruskal's algorithm
- 8. C · At most twice the size of a minimum vertex cover
Full step-by-step solutions: practise this topic on examproblems.com.