1.Easy
Space complexity measures:
- AThe disk space of the program file once it is compiled
- BThe amount of memory an algorithm needs as input grows
- CThe number of lines of code
- DThe physical size of the computer
2.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
- CFreeing memory after a function returns
- DWriting comments next to each line of code
3.Easy
What is O(2ⁿ) growth called?
- ALinear
- BLogarithmic
- CPolynomial
- DExponential
4.Medium
Why is the base of a logarithm usually left out in Big O, as in O(log n)?
- ALogarithms are always rounded to integers
- BThe base only matters for small n
- CAll logarithms in computer science have base 10, so it is implied
- DLogarithms with different bases differ only by a constant factor
5.Medium
What is the running time of LSD radix sort on n integers with d digits in base k?
- AO(n log n)
- BO(n²)
- CO(dn log k)
- DO(d(n + k))
6.Medium
What does it mean that a problem has optimal substructure?
- AThe problem can be solved in constant time
- BThe problem has exactly one optimal solution, which every subproblem shares
- CAn optimal solution can be built from optimal solutions of its subproblems
- DEvery subproblem has the same size
7.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX reduces to a problem in P, and X is in NP
- BX has no polynomial algorithm, and X is decidable
- CX is in NP, and a known NP-complete problem reduces to X in polynomial time
- DX is in P, and X reduces to SAT
8.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
Answer key
- 1. B · The amount of memory an algorithm needs as input grows
- 2. B · Storing the results of function calls so repeated calls are answered from memory
- 3. D · Exponential
- 4. D · Logarithms with different bases differ only by a constant factor
- 5. D · O(d(n + k))
- 6. C · An optimal solution can be built from optimal solutions of its subproblems
- 7. C · X is in NP, and a known NP-complete problem reduces to X in polynomial time
- 8. D · Kruskal's algorithm
Full step-by-step solutions: practise this topic on examproblems.com.