1.Easy
What is a brute-force algorithm?
- AOne that tries all possible candidate solutions
- BOne that runs on many processors
- COne that always uses recursion
- DOne that guesses an answer at random
2.Easy
An O(n) algorithm takes 3 seconds for n = 1 million. About how long does it take for n = 2 million?
- A3 seconds
- B6 seconds
- C12 seconds
- D9 seconds
3.Easy
A loop starts with i = 1 and doubles i each iteration until i > n. How many iterations does it run?
- AAbout n / 2
- BAbout n²
- CAbout n
- DAbout log₂ n
4.Medium
In the activity selection problem, which greedy rule always gives a maximum number of non-overlapping activities?
- APick the activity that starts earliest
- BPick the activity with the fewest overlaps first, then repeat with the compatible ones
- CPick the shortest activity first
- DPick the activity that finishes earliest, then repeat with the compatible ones
5.Medium
Why do many library sorting routines switch to insertion sort for very small subarrays?
- AInsertion sort has little overhead and is fast on small or nearly sorted inputs
- BRecursive algorithms cannot handle arrays below 10 elements
- CInsertion sort is O(n log n) in the worst case
- DInsertion sort uses less memory than any other sorting algorithm on large inputs
6.Medium
Which sorting algorithm is stable?
- AQuicksort (typical in-place version)
- BHeap sort
- CSelection sort (typical version)
- DMerge sort
7.Hard
Which statement about selecting the k-th smallest element of an unsorted array is correct?
- AQuickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
- BSelection is only possible in O(n²)
- CSelection always needs Ω(n log n) because it requires sorting
- DQuickselect runs in O(log n) worst case, because it recurses on only one side of the pivot
8.Hard
What is the running time of Dijkstra's algorithm with a binary heap on a graph with V vertices and E edges?
- AO(V³)
- BO(V + E)
- CO((V + E) log V)
- DO(V × E)
Answer key
- 1. A · One that tries all possible candidate solutions
- 2. B · 6 seconds
- 3. D · About log₂ n
- 4. D · Pick the activity that finishes earliest, then repeat with the compatible ones
- 5. A · Insertion sort has little overhead and is fast on small or nearly sorted inputs
- 6. D · Merge sort
- 7. A · Quickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
- 8. C · O((V + E) log V)
Full step-by-step solutions: practise this topic on examproblems.com.