1.Easy
An O(n²) algorithm takes 1 second for n = 1000. About how long does it take for n = 2000?
- A1 second
- B4 seconds
- C2 seconds
- D8 seconds
2.Easy
Which notation describes an upper bound on growth?
- ALittle omega
- BBig Omega
- CBig O
- DBig Theta
3.Easy
What is memoisation?
- AConverting recursion into an equivalent loop automatically so no call stack is needed
- BStoring the results of function calls so repeated calls are answered from memory
- CWriting comments next to each line of code
- DFreeing memory after a function returns
4.Medium
Which algorithm finds the shortest paths from one source in a graph with non-negative edge weights?
- ADijkstra's algorithm
- BDepth-first search
- CBellman–Ford is required in all cases
- DKruskal's algorithm
5.Medium
How much stack space does a simple recursive factorial function fact(n) = n × fact(n − 1) use?
- AO(n²)
- BO(log n)
- CO(n)
- DO(1)
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(n)
- BO(n²)
- CO(log n)
- DO(n log n)
7.Hard
The Held–Karp dynamic programming algorithm solves the travelling salesman problem exactly. What is its running time for n cities?
- AO(n!)
- BO(2n²)
- CO(n³)
- DO(n² 2ⁿ)
8.Hard
To show that a new problem X is NP-hard, what must you do?
- AShow that X can be verified in polynomial time
- BReduce a known NP-hard problem to X in polynomial time
- CShow that X has no polynomial algorithm for small inputs
- DReduce X to a known NP-hard problem in polynomial time
Answer key
- 1. B · 4 seconds
- 2. C · Big O
- 3. B · Storing the results of function calls so repeated calls are answered from memory
- 4. A · Dijkstra's algorithm
- 5. C · O(n)
- 6. D · O(n log n)
- 7. D · O(n² 2ⁿ)
- 8. B · Reduce a known NP-hard problem to X in polynomial time
Full step-by-step solutions: practise this topic on examproblems.com.