1.Easy
What is the base case of a recursive function?
- AThe first line of the function
- BThe case with the largest input, which is handled before any recursive calls
- CA case that is answered directly without making another recursive call
- DThe call that uses the most memory
2.Easy
What are the three steps of a divide-and-conquer algorithm?
- AGuess, check, repeat
- BRead, compute, write
- CDivide, conquer, combine
- DSort, search, return
3.Easy
What is O(2ⁿ) growth called?
- AExponential
- BLogarithmic
- CLinear
- DPolynomial
4.Medium
The lower bound for comparison-based sorting in the worst case is:
- AΩ(n log n)
- BΩ(n²)
- CΩ(log n)
- DΩ(n)
5.Medium
What does the recurrence T(n) = T(n − 1) + O(1) solve to?
- AO(n)
- BO(n²)
- CO(2ⁿ)
- DO(log n)
6.Medium
In the activity selection problem, which greedy rule always gives a maximum number of non-overlapping activities?
- APick the activity with the fewest overlaps first, then repeat with the compatible ones
- BPick the activity that finishes earliest, then repeat with the compatible ones
- CPick the activity that starts earliest
- DPick the shortest activity first
7.Hard
Which technique gives an expected O(n log n) running time for quicksort on any input?
- AChoosing the pivot uniformly at random
- BUsing recursion only on the left side
- CAlways choosing the first element
- DSorting the input before running quicksort
8.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX has no polynomial algorithm, and X is decidable
- BX is in P, and X reduces to SAT
- CX is in NP, and a known NP-complete problem reduces to X in polynomial time
- DX reduces to a problem in P, and X is in NP
Answer key
- 1. C · A case that is answered directly without making another recursive call
- 2. C · Divide, conquer, combine
- 3. A · Exponential
- 4. A · Ω(n log n)
- 5. A · O(n)
- 6. B · Pick the activity that finishes earliest, then repeat with the compatible ones
- 7. A · Choosing the pivot uniformly at random
- 8. C · X is in NP, and a known NP-complete problem reduces to X in polynomial time
Full step-by-step solutions: practise this topic on examproblems.com.