1.Easy
What does the worst-case running time of an algorithm describe?
- AThe time it takes on a slow computer
- BThe maximum time it takes over all inputs of size n
- CThe expected time it takes on a random input of size n
- DThe time it takes on the smallest input
2.Easy
What are the three steps of a divide-and-conquer algorithm?
- AGuess, check, repeat
- BSort, search, return
- CDivide, conquer, combine
- DRead, compute, write
3.Easy
Which sorting algorithm chooses a pivot and partitions the array into smaller and larger elements?
- AMerge sort
- BQuicksort
- CBubble sort
- DInsertion sort
4.Medium
Quicksort always uses the first element as pivot. On which input does it show its worst-case behaviour?
- AAn array that is already sorted
- BAn array of length 2
- CAn array whose elements are all different
- DAn array in random order
5.Medium
In a sorted array, you look for two elements that sum to a target by moving one pointer from each end inwards. What is the time complexity?
- AO(log n)
- BO(n)
- CO(n log n)
- DO(n²)
6.Medium
What does the recurrence T(n) = 2T(n − 1) + O(1) solve to?
- AO(n)
- BO(n log n)
- CO(2ⁿ)
- DO(n²)
7.Hard
The Held–Karp dynamic programming algorithm solves the travelling salesman problem exactly. What is its running time for n cities?
- AO(2n²)
- BO(n² 2ⁿ)
- CO(n!)
- DO(n³)
8.Hard
Which definition of the class P is correct?
- AProblems whose solutions can be checked but never found in polynomial time
- BDecision problems solvable by a deterministic algorithm in polynomial time
- CProblems that need exponential time on every computer
- DProblems that can be solved in parallel
Answer key
- 1. B · The maximum time it takes over all inputs of size n
- 2. C · Divide, conquer, combine
- 3. B · Quicksort
- 4. A · An array that is already sorted
- 5. B · O(n)
- 6. C · O(2ⁿ)
- 7. B · O(n² 2ⁿ)
- 8. B · Decision problems solvable by a deterministic algorithm in polynomial time
Full step-by-step solutions: practise this topic on examproblems.com.