1.Easy
An O(n) algorithm takes 3 seconds for n = 1 million. About how long does it take for n = 2 million?
- A12 seconds
- B9 seconds
- C6 seconds
- D3 seconds
2.Easy
An algorithm's running time is O(n). What is this growth called?
- ALogarithmic
- BConstant
- CQuadratic
- DLinear
3.Easy
What are the three steps of a divide-and-conquer algorithm?
- ARead, compute, write
- BDivide, conquer, combine
- CGuess, check, repeat
- DSort, search, return
4.Medium
What is the time complexity of: for i = 1 to n: for j = 1 to i: do O(1) work?
- AO(n³)
- BO(n)
- CO(n²)
- DO(n log n)
5.Medium
Dynamic programming is useful when a problem has:
- AOverlapping subproblems and optimal substructure
- BNo subproblems at all, so it can be solved in one step
- COnly random inputs
- DA single loop
6.Medium
Why is the base of a logarithm usually left out in Big O, as in O(log n)?
- AAll logarithms in computer science have base 10, so it is implied
- BLogarithms are always rounded to integers
- CThe base only matters for small n
- DLogarithms with different bases differ only by a constant factor
7.Hard
Which technique gives an expected O(n log n) running time for quicksort on any input?
- AUsing recursion only on the left side
- BSorting the input before running quicksort
- CChoosing the pivot uniformly at random
- DAlways choosing the first element
8.Hard
Which of these satisfiability problems is known to be solvable in polynomial time?
- A2-SAT, where each clause has at most two literals
- B3-SAT, where each clause has exactly three literals
- CCircuit satisfiability
- DGeneral SAT on formulas in conjunctive normal form
Answer key
- 1. C · 6 seconds
- 2. D · Linear
- 3. B · Divide, conquer, combine
- 4. C · O(n²)
- 5. A · Overlapping subproblems and optimal substructure
- 6. D · Logarithms with different bases differ only by a constant factor
- 7. C · Choosing the pivot uniformly at random
- 8. A · 2-SAT, where each clause has at most two literals
Full step-by-step solutions: practise this topic on examproblems.com.