1.Easy
Which of these running times is polynomial?
- AO(n!)
- BO(n³)
- CO(nⁿ)
- DO(2ⁿ)
2.Easy
What is the base case of a recursive function?
- AA case that is answered directly without making another recursive call
- BThe call that uses the most memory
- CThe first line of the function
- DThe case with the largest input, which is handled before any recursive calls
3.Easy
What does f(n) = Θ(g(n)) mean?
- Af grows strictly faster than g
- Bf grows strictly slower than g
- Cf grows at the same rate as g, bounded above and below by constant multiples of g
- Df is always smaller than g for every n, so g bounds it from above but never from below
4.Medium
What does the recurrence T(n) = T(n − 1) + O(n) solve to?
- AO(2ⁿ)
- BO(n)
- CO(n²)
- DO(n log n)
5.Medium
What does the Floyd–Warshall algorithm compute, and how fast?
- AShortest paths from one source vertex to all others in O(V + E)
- BA minimum spanning tree in O(E log V)
- CA topological order in O(V²)
- DShortest paths between all pairs of vertices in O(V³)
6.Medium
Which statement about a recursive function without a reachable base case is correct?
- AThe compiler always turns it into a loop that ends safely
- BIt keeps calling itself until the call stack overflows
- CIt returns 0 automatically
- DIt runs in O(1) time
7.Hard
Topological sorting is possible only for:
- AUndirected graphs
- BGraphs with negative weights
- CDirected acyclic graphs
- DComplete graphs
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 runs Dijkstra's algorithm twice and compares the two distance results
- CIt counts the cycles with depth-first search
- DIt checks whether any edge has a negative weight
Answer key
- 1. B · O(n³)
- 2. A · A case that is answered directly without making another recursive call
- 3. C · f grows at the same rate as g, bounded above and below by constant multiples of g
- 4. C · O(n²)
- 5. D · Shortest paths between all pairs of vertices in O(V³)
- 6. B · It keeps calling itself until the call stack overflows
- 7. C · Directed acyclic graphs
- 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.