1.Easy
How does selection sort work?
- AIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- BIt inserts each element into a growing sorted part by shifting
- CIt repeatedly swaps neighbouring elements that are in the wrong order
- DIt splits the array in halves and merges them
2.Easy
What is the best-case time complexity of insertion sort, on an already sorted array?
- AO(1)
- BO(n log n)
- CO(n²)
- DO(n)
3.Easy
What is the time complexity of depth-first search on a graph stored as adjacency lists?
- AO(V + E)
- BO(V × E)
- CO(V²)
- DO(E log V)
4.Medium
With coins of 1, 3 and 4 and an amount of 6, how many coins does the greedy "largest coin first" method use, compared to the optimum?
- AGreedy uses 2 coins; the optimum is 2
- BGreedy uses 3 coins; the optimum is 2
- CGreedy uses 4 coins; the optimum is 3
- DGreedy uses 3 coins; the optimum is 3
5.Medium
The time complexity of naive recursive Fibonacci (fib(n) = fib(n−1) + fib(n−2)) is:
- ALogarithmic
- BExponential
- CLinear
- DConstant
6.Medium
What does the recurrence T(n) = T(n − 1) + O(1) solve to?
- AO(n)
- BO(2ⁿ)
- CO(log n)
- DO(n²)
7.Hard
Topological sorting is possible only for:
- AUndirected graphs
- BGraphs with negative weights
- CDirected acyclic graphs
- DComplete graphs
8.Hard
Which algorithm finds a minimum spanning tree by repeatedly adding the cheapest edge that does not form a cycle?
- AFloyd–Warshall
- BPrim's algorithm starting from one node
- CDijkstra's algorithm
- DKruskal's algorithm
Answer key
- 1. A · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 2. D · O(n)
- 3. A · O(V + E)
- 4. B · Greedy uses 3 coins; the optimum is 2
- 5. B · Exponential
- 6. A · O(n)
- 7. C · Directed acyclic graphs
- 8. D · Kruskal's algorithm
Full step-by-step solutions: practise this topic on examproblems.com.