1.Easy
What is recursion?
- AA type of data structure
- BA sorting method
- CA loop that never ends
- DA function that calls itself on smaller inputs
2.Easy
Space complexity measures:
- AThe physical size of the computer
- BThe disk space of the program file once it is compiled
- CThe number of lines of code
- DThe amount of memory an algorithm needs as input grows
3.Easy
What is memoisation?
- AStoring the results of function calls so repeated calls are answered from memory
- BWriting comments next to each line of code
- CFreeing memory after a function returns
- DConverting recursion into an equivalent loop automatically so no call stack is needed
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
Why does dynamic programming give no real speed-up for merge sort?
- AIts subproblems do not overlap, so there is nothing to reuse
- BDynamic programming only works on graph problems, not on arrays
- CMerge sort has no recursive structure
- DMerge sort is already O(n)
6.Medium
The time complexity of naive recursive Fibonacci (fib(n) = fib(n−1) + fib(n−2)) is:
- AConstant
- BLinear
- CLogarithmic
- DExponential
7.Hard
Which algorithm finds a minimum spanning tree by repeatedly adding the cheapest edge that does not form a cycle?
- ADijkstra's algorithm
- BFloyd–Warshall
- CPrim's algorithm starting from one node
- DKruskal's algorithm
8.Hard
Is 22n in O(2ⁿ)?
- AYes, because both are exponential
- BNo, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
- CYes, because constant factors in the exponent are always ignored in Big O
- DNo, because 22n grows more slowly than 2ⁿ
Answer key
- 1. D · A function that calls itself on smaller inputs
- 2. D · The amount of memory an algorithm needs as input grows
- 3. A · Storing the results of function calls so repeated calls are answered from memory
- 4. B · O(n log n + k log n)
- 5. A · Its subproblems do not overlap, so there is nothing to reuse
- 6. D · Exponential
- 7. D · Kruskal's algorithm
- 8. B · No, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
Full step-by-step solutions: practise this topic on examproblems.com.