1.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- AQuicksort
- BHeap sort
- CMerge sort
- DBubble sort
2.Easy
What does f(n) = Θ(g(n)) mean?
- Af grows strictly slower than g
- Bf grows strictly faster than g
- Cf grows at the same rate as g, bounded above and below by constant multiples of g
- Df is always smaller than g for every n, so g bounds it from above but never from below
3.Easy
How much extra memory does a standard array-based merge sort use?
- AO(log n)
- BO(n)
- CO(1)
- DO(n²)
4.Medium
You sort an array of n elements once and then answer k membership queries with binary search. What is the total cost?
- AO(nk)
- BO(n log n + k log n)
- CO(k n log n)
- DO(n + k)
5.Medium
What is the time complexity of: for i = 1 to n: (j = 1; while j < n: j = j × 2)?
- AO(n²)
- BO(log n)
- CO(n log n)
- DO(n)
6.Medium
What does amortised analysis measure?
- AThe average cost per operation over a worst-case sequence of operations
- BThe cost of the single most expensive operation anywhere in the sequence
- CThe cost of an algorithm on the best input
- DThe expected cost over random inputs
7.Hard
Karatsuba multiplication satisfies T(n) = 3T(n/2) + O(n). What does this solve to?
- AΘ(nlog₂ 3), about n1.585
- BΘ(n²)
- CΘ(n3)
- DΘ(n log n)
8.Hard
How does the Bellman–Ford algorithm detect a negative-weight cycle reachable from the source?
- AAfter V − 1 rounds, it checks whether any edge can still be relaxed
- BIt counts the cycles with depth-first search
- CIt runs Dijkstra's algorithm twice and compares the two distance results
- DIt checks whether any edge has a negative weight
Answer key
- 1. D · Bubble sort
- 2. C · f grows at the same rate as g, bounded above and below by constant multiples of g
- 3. B · O(n)
- 4. B · O(n log n + k log n)
- 5. C · O(n log n)
- 6. A · The average cost per operation over a worst-case sequence of operations
- 7. A · Θ(nlog₂ 3), about n1.585
- 8. A · After V − 1 rounds, it checks whether any edge can still be relaxed
Full step-by-step solutions: practise this topic on examproblems.com.