1.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(n)
- BO(1)
- CO(log n)
- DO(n log n)
2.Easy
What are the three steps of a divide-and-conquer algorithm?
- ASort, search, return
- BGuess, check, repeat
- CDivide, conquer, combine
- DRead, compute, write
3.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- AMerge sort
- BBubble sort
- CHeap sort
- DQuicksort
4.Medium
Which sorting algorithm is stable?
- ASelection sort (typical version)
- BMerge sort
- CHeap sort
- DQuicksort (typical in-place version)
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
What does the recurrence T(n) = 2T(n − 1) + O(1) solve to?
- AO(n log n)
- BO(n)
- CO(n²)
- DO(2ⁿ)
7.Hard
To show that a new problem X is NP-hard, what must you do?
- AReduce X to a known NP-hard problem in polynomial time
- BReduce a known NP-hard problem to X in polynomial time
- CShow that X has no polynomial algorithm for small inputs
- DShow that X can be verified in polynomial time
8.Hard
What is the time complexity of: for i = 1 to n: for (j = i; j ≤ n; j = j + i) do O(1) work?
- AO(n √n)
- BO(n²)
- CO(n)
- DO(n log n)
Answer key
- 1. A · O(n)
- 2. C · Divide, conquer, combine
- 3. B · Bubble sort
- 4. B · Merge sort
- 5. D · Shortest paths between all pairs of vertices in O(V³)
- 6. D · O(2ⁿ)
- 7. B · Reduce a known NP-hard problem to X in polynomial time
- 8. D · O(n log n)
Full step-by-step solutions: practise this topic on examproblems.com.