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 n
- CAbout log₂ n
- DAbout n / 2
2.Easy
What is O(2ⁿ) growth called?
- ALinear
- BExponential
- CLogarithmic
- DPolynomial
3.Easy
What is the base case of a recursive function?
- AThe case with the largest input, which is handled before any recursive calls
- BThe first line of the function
- CA case that is answered directly without making another recursive call
- DThe call that uses the most memory
4.Medium
How many levels does the recursion of merge sort have for an array of n elements?
- AAbout n
- BAbout n / 2
- CAbout log₂ n
- DAbout √n
5.Medium
Breadth-first search on an unweighted graph finds:
- AThe minimum spanning tree
- BShortest paths in number of edges from the start node
- CShortest paths in graphs that contain negative edge weights
- DA topological order in all graphs
6.Medium
What does the Floyd–Warshall algorithm compute, and how fast?
- AA topological order in O(V²)
- BA minimum spanning tree in O(E log V)
- CShortest paths from one source vertex to all others in O(V + E)
- DShortest paths between all pairs of vertices in O(V³)
7.Hard
Topological sorting is possible only for:
- AGraphs with negative weights
- BComplete graphs
- CUndirected graphs
- DDirected acyclic graphs
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
- BIt runs Dijkstra's algorithm twice and compares the two distance results
- CIt checks whether any edge has a negative weight
- DAfter V − 1 rounds, it checks whether any edge can still be relaxed
Answer key
- 1. C · About log₂ n
- 2. B · Exponential
- 3. C · A case that is answered directly without making another recursive call
- 4. C · About log₂ n
- 5. B · Shortest paths in number of edges from the start node
- 6. D · Shortest paths between all pairs of vertices in O(V³)
- 7. D · Directed acyclic graphs
- 8. D · After V − 1 rounds, it checks whether any edge can still be relaxed
Full step-by-step solutions: practise this topic on examproblems.com.