1.Easy
What is the worst-case time complexity of merge sort?
- AO(n)
- BO(n log n)
- CO(log n)
- DO(n²)
2.Easy
What is the worst-case time complexity of insertion sort?
- AO(n²)
- BO(n log n)
- CO(log n)
- DO(n)
3.Easy
What does the average-case running time describe?
- AThe expected time over a given distribution of inputs of size n
- BThe time for an input of average length
- CThe time on the most common computer
- DThe middle value between the best-case and worst-case running times
4.Medium
Breadth-first search on an unweighted graph finds:
- AShortest paths in graphs that contain negative edge weights
- BThe minimum spanning tree
- CA topological order in all graphs
- DShortest paths in number of edges from the start node
5.Medium
What is the time complexity of: for i = 1 to n: for j = 1 to i: do O(1) work?
- AO(n²)
- BO(n log n)
- CO(n)
- DO(n³)
6.Medium
What is the running time of LSD radix sort on n integers with d digits in base k?
- AO(dn log k)
- BO(d(n + k))
- CO(n²)
- DO(n log n)
7.Hard
What are the time and space costs of computing the n-th Fibonacci number with a loop that keeps only the last two values?
- AO(2ⁿ) time and O(1) space
- BO(n) time and O(n) space
- CO(log n) time and O(n) space
- DO(n) time and O(1) space
8.Hard
Topological sorting is possible only for:
- AUndirected graphs
- BDirected acyclic graphs
- CComplete graphs
- DGraphs with negative weights
Answer key
- 1. B · O(n log n)
- 2. A · O(n²)
- 3. A · The expected time over a given distribution of inputs of size n
- 4. D · Shortest paths in number of edges from the start node
- 5. A · O(n²)
- 6. B · O(d(n + k))
- 7. D · O(n) time and O(1) space
- 8. B · Directed acyclic graphs
Full step-by-step solutions: practise this topic on examproblems.com.