1.Easy
How much extra memory does a standard array-based merge sort use?
- AO(log n)
- BO(n)
- CO(n²)
- DO(1)
2.Easy
What is memoisation?
- AStoring the results of function calls so repeated calls are answered from memory
- BConverting recursion into an equivalent loop automatically so no call stack is needed
- CFreeing memory after a function returns
- DWriting comments next to each line of code
3.Easy
How does selection sort work?
- AIt repeatedly swaps neighbouring elements that are in the wrong order
- BIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- CIt inserts each element into a growing sorted part by shifting
- DIt splits the array in halves and merges them
4.Medium
Why does dynamic programming give no real speed-up for merge sort?
- AIts subproblems do not overlap, so there is nothing to reuse
- BMerge sort is already O(n)
- CDynamic programming only works on graph problems, not on arrays
- DMerge sort has no recursive structure
5.Medium
Why do many library sorting routines switch to insertion sort for very small subarrays?
- ARecursive algorithms cannot handle arrays below 10 elements
- BInsertion sort uses less memory than any other sorting algorithm on large inputs
- CInsertion sort is O(n log n) in the worst case
- DInsertion sort has little overhead and is fast on small or nearly sorted inputs
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(log n)
- BO(n²)
- CO(n log n)
- DO(n)
7.Hard
Why can Dijkstra's algorithm give wrong results when some edge weights are negative?
- AIt goes into an infinite loop on every negative edge
- BIt only works on undirected graphs
- CNegative numbers cannot be stored in a priority queue
- DA vertex is finalised when extracted, but a later negative edge could still give it a shorter path
8.Hard
What is the amortised cost of incrementing a binary counter, given that one increment may flip many bits?
- AO(n) per increment
- BO(log n) per increment
- CO(n log n) per increment
- DO(1) per increment
Answer key
- 1. B · O(n)
- 2. A · Storing the results of function calls so repeated calls are answered from memory
- 3. B · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 4. A · Its subproblems do not overlap, so there is nothing to reuse
- 5. D · Insertion sort has little overhead and is fast on small or nearly sorted inputs
- 6. C · O(n log n)
- 7. D · A vertex is finalised when extracted, but a later negative edge could still give it a shorter path
- 8. D · O(1) per increment
Full step-by-step solutions: practise this topic on examproblems.com.