1.Easy
What does the worst-case running time of an algorithm describe?
- AThe time it takes on the smallest input
- BThe expected time it takes on a random input of size n
- CThe maximum time it takes over all inputs of size n
- DThe time it takes on a slow computer
2.Easy
What is the best-case time complexity of insertion sort, on an already sorted array?
- AO(1)
- BO(n log n)
- CO(n)
- DO(n²)
3.Easy
Which notation describes an upper bound on growth?
- ABig O
- BBig Theta
- CBig Omega
- DLittle omega
4.Medium
Which sorting algorithm is stable?
- AQuicksort (typical in-place version)
- BHeap sort
- CMerge sort
- DSelection sort (typical version)
5.Medium
What does it mean that a problem has optimal substructure?
- AAn optimal solution can be built from optimal solutions of its subproblems
- BThe problem has exactly one optimal solution, which every subproblem shares
- CEvery subproblem has the same size
- DThe problem can be solved in constant time
6.Medium
What is the time complexity of the Bellman–Ford algorithm on a graph with V vertices and E edges?
- AO(E log V)
- BO(V + E)
- CO(V × E)
- DO(V³ × E)
7.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX is in NP, and a known NP-complete problem reduces to X in polynomial time
- BX is in P, and X reduces to SAT
- CX reduces to a problem in P, and X is in NP
- DX has no polynomial algorithm, and X is decidable
8.Hard
Karatsuba multiplication satisfies T(n) = 3T(n/2) + O(n). What does this solve to?
- AΘ(n log n)
- BΘ(n3)
- CΘ(nlog₂ 3), about n1.585
- DΘ(n²)
Answer key
- 1. C · The maximum time it takes over all inputs of size n
- 2. C · O(n)
- 3. A · Big O
- 4. C · Merge sort
- 5. A · An optimal solution can be built from optimal solutions of its subproblems
- 6. C · O(V × E)
- 7. A · X is in NP, and a known NP-complete problem reduces to X in polynomial time
- 8. C · Θ(nlog₂ 3), about n1.585
Full step-by-step solutions: practise this topic on examproblems.com.