1.Easy
An algorithm with two nested loops, each running n times, typically has which complexity?
- AO(log n)
- BO(2n)
- CO(n²)
- DO(n)
2.Easy
An algorithm's running time is O(n). What is this growth called?
- ALinear
- BConstant
- CQuadratic
- DLogarithmic
3.Easy
Which design strategy does merge sort use?
- AGreedy choice
- BBrute force
- CDivide and conquer
- DDynamic programming
4.Medium
Why do many library sorting routines switch to insertion sort for very small subarrays?
- ARecursive algorithms cannot handle arrays below 10 elements
- BInsertion sort is O(n log n) in the worst case
- CInsertion sort uses less memory than any other sorting algorithm on large inputs
- DInsertion sort has little overhead and is fast on small or nearly sorted inputs
5.Medium
What is the worst-case time complexity of quicksort?
- AO(log n)
- BO(n²)
- CO(n log n)
- DO(n)
6.Medium
What does the recurrence T(n) = T(n − 1) + O(1) solve to?
- AO(n²)
- BO(n)
- CO(log n)
- DO(2ⁿ)
7.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX is in P, and X reduces to SAT
- 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 reduces to a problem in P, and X is in NP
8.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² 2ⁿ)
- DO(n!)
Answer key
- 1. C · O(n²)
- 2. A · Linear
- 3. C · Divide and conquer
- 4. D · Insertion sort has little overhead and is fast on small or nearly sorted inputs
- 5. B · O(n²)
- 6. B · O(n)
- 7. C · X is in NP, and a known NP-complete problem reduces to X in polynomial time
- 8. C · O(n² 2ⁿ)
Full step-by-step solutions: practise this topic on examproblems.com.