1.Easy
What is the base case of a recursive function?
- AThe call that uses the most memory
- BA case that is answered directly without making another recursive call
- CThe case with the largest input, which is handled before any recursive calls
- DThe first line of the function
2.Easy
What does the average-case running time describe?
- AThe expected time over a given distribution of inputs of size n
- BThe middle value between the best-case and worst-case running times
- CThe time for an input of average length
- DThe time on the most common computer
3.Easy
What is an algorithm?
- AA data structure that stores numbers
- BA finite sequence of well-defined steps that solves a problem
- CAny computer program that has a graphical interface
- DA programming language designed for writing mathematical formulas
4.Medium
Dynamic programming is useful when a problem has:
- AOnly random inputs
- BOverlapping subproblems and optimal substructure
- CNo subproblems at all, so it can be solved in one step
- DA single loop
5.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- AYes, because Big O is an upper bound and n² grows no faster than n³
- BNo, because Big O must always state the exact growth rate of the function
- CNo, because n³ is smaller than n² for large n
- DYes, but only if n is smaller than 100
6.Medium
What is the running time of LSD radix sort on n integers with d digits in base k?
- AO(d(n + k))
- BO(dn log k)
- CO(n²)
- DO(n log n)
7.Hard
Taking both endpoints of every edge in a maximal matching gives a vertex cover. How good is this cover?
- AAt most log n times the minimum
- BOf unknown quality compared to the optimum
- CAlways a minimum vertex cover
- DAt most twice the size of a minimum vertex cover
8.Hard
The 0/1 knapsack problem solved with dynamic programming takes O(nW) time. Why is this called pseudo-polynomial?
- ABecause the algorithm is randomised and its running time varies with each input
- BBecause it only works for W = 0
- CW is a number, so the time is exponential in the number of bits used to write W
- DBecause n is always small
Answer key
- 1. B · A case that is answered directly without making another recursive call
- 2. A · The expected time over a given distribution of inputs of size n
- 3. B · A finite sequence of well-defined steps that solves a problem
- 4. B · Overlapping subproblems and optimal substructure
- 5. A · Yes, because Big O is an upper bound and n² grows no faster than n³
- 6. A · O(d(n + k))
- 7. D · At most twice the size of a minimum vertex cover
- 8. C · W is a number, so the time is exponential in the number of bits used to write W
Full step-by-step solutions: practise this topic on examproblems.com.