1.Easy
What does f(n) = Θ(g(n)) mean?
- Af grows strictly slower than g
- Bf grows strictly faster than g
- Cf is always smaller than g for every n, so g bounds it from above but never from below
- Df grows at the same rate as g, bounded above and below by constant multiples of g
2.Easy
What is memoisation?
- AStoring the results of function calls so repeated calls are answered from memory
- BFreeing memory after a function returns
- CWriting comments next to each line of code
- DConverting recursion into an equivalent loop automatically so no call stack is needed
3.Easy
What does the average-case running time describe?
- AThe time for an input of average length
- BThe time on the most common computer
- CThe expected time over a given distribution of inputs of size n
- DThe middle value between the best-case and worst-case running times
4.Medium
What is the worst-case time complexity of quicksort?
- AO(log n)
- BO(n log n)
- CO(n)
- DO(n²)
5.Medium
A greedy algorithm:
- AAlways gives the optimal solution
- BUses only recursion
- CTries every possible solution
- DMakes the locally best choice at each step
6.Medium
With coins of 1, 3 and 4 and an amount of 6, how many coins does the greedy "largest coin first" method use, compared to the optimum?
- AGreedy uses 3 coins; the optimum is 3
- BGreedy uses 4 coins; the optimum is 3
- CGreedy uses 3 coins; the optimum is 2
- DGreedy uses 2 coins; the optimum is 2
7.Hard
The halting problem shows that:
- ALoops should be avoided
- BEvery program eventually halts
- CNo algorithm can decide for every program and input whether it halts
- DSome programs run faster on faster computers, so halting depends on hardware
8.Hard
How does the Bellman–Ford algorithm detect a negative-weight cycle reachable from the source?
- AIt counts the cycles with depth-first search
- BIt checks whether any edge has a negative weight
- CAfter V − 1 rounds, it checks whether any edge can still be relaxed
- DIt runs Dijkstra's algorithm twice and compares the two distance results
Answer key
- 1. D · f grows at the same rate as g, bounded above and below by constant multiples of g
- 2. A · Storing the results of function calls so repeated calls are answered from memory
- 3. C · The expected time over a given distribution of inputs of size n
- 4. D · O(n²)
- 5. D · Makes the locally best choice at each step
- 6. C · Greedy uses 3 coins; the optimum is 2
- 7. C · No algorithm can decide for every program and input whether it halts
- 8. C · After V − 1 rounds, it checks whether any edge can still be relaxed
Full step-by-step solutions: practise this topic on examproblems.com.