1.Easy
Which sorting algorithm chooses a pivot and partitions the array into smaller and larger elements?
- AMerge sort
- BBubble sort
- CInsertion sort
- DQuicksort
2.Easy
Which complexity class grows fastest for large n?
- AO(n log n)
- BO(n²)
- CO(n³)
- DO(2ⁿ)
3.Easy
What is memoisation?
- AFreeing memory after a function returns
- BConverting recursion into an equivalent loop automatically so no call stack is needed
- CStoring the results of function calls so repeated calls are answered from memory
- DWriting comments next to each line of code
4.Medium
How much stack space does a simple recursive factorial function fact(n) = n × fact(n − 1) use?
- AO(n)
- BO(1)
- CO(n²)
- DO(log n)
5.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(n)
- BO(n log n)
- CO(n²)
- DO(log n)
6.Medium
What is the time complexity of the Bellman–Ford algorithm on a graph with V vertices and E edges?
- AO(V + E)
- BO(V × E)
- CO(V³ × E)
- DO(E log V)
7.Hard
How is the travelling salesman problem classified?
- AThe decision version is in P but the optimisation version is NP-complete
- BIt is undecidable
- CThe decision version is NP-complete and the optimisation version is NP-hard
- DIt is in P because Dijkstra's algorithm solves it by visiting every city once
8.Hard
Why is the average lookup in a hash table O(1) but the worst case O(n)?
- AMany keys may collide into the same bucket
- BHash functions are slow
- CKeys must be sorted first
- DArrays have O(n) access
Answer key
- 1. D · Quicksort
- 2. D · O(2ⁿ)
- 3. C · Storing the results of function calls so repeated calls are answered from memory
- 4. A · O(n)
- 5. A · O(n)
- 6. B · O(V × E)
- 7. C · The decision version is NP-complete and the optimisation version is NP-hard
- 8. A · Many keys may collide into the same bucket
Full step-by-step solutions: practise this topic on examproblems.com.