1.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- AMerge sort
- BBubble sort
- CHeap sort
- DQuicksort
2.Easy
What does binary search require of its input?
- AThe array must have no more than 1000 elements
- BThe array must be sorted
- CThe array must contain only positive numbers
- DThe array length must be a power of two
3.Easy
What is the worst-case time complexity of insertion sort?
- AO(n log n)
- BO(n²)
- CO(n)
- DO(log n)
4.Medium
In a sorted array, you look for two elements that sum to a target by moving one pointer from each end inwards. What is the time complexity?
- AO(n)
- BO(log n)
- CO(n²)
- DO(n log n)
5.Medium
Which algorithm finds the shortest paths from one source in a graph with non-negative edge weights?
- ADepth-first search
- BKruskal's algorithm
- CBellman–Ford is required in all cases
- DDijkstra's algorithm
6.Medium
Dynamic programming is useful when a problem has:
- AA single loop
- BOnly random inputs
- COverlapping subproblems and optimal substructure
- DNo subproblems at all, so it can be solved in one step
7.Hard
Which statement about P and NP is correct?
- ANP means "not polynomial"
- BEvery problem in P is also in NP
- CNP problems cannot be verified quickly
- DIt has been proven that P ≠ NP
8.Hard
What is the amortised cost of incrementing a binary counter, given that one increment may flip many bits?
- AO(log n) per increment
- BO(n log n) per increment
- CO(n) per increment
- DO(1) per increment
Answer key
- 1. B · Bubble sort
- 2. B · The array must be sorted
- 3. B · O(n²)
- 4. A · O(n)
- 5. D · Dijkstra's algorithm
- 6. C · Overlapping subproblems and optimal substructure
- 7. B · Every problem in P is also in NP
- 8. D · O(1) per increment
Full step-by-step solutions: practise this topic on examproblems.com.