1.Easy
Which sorting algorithm chooses a pivot and partitions the array into smaller and larger elements?
- ABubble sort
- BInsertion sort
- CQuicksort
- DMerge sort
2.Easy
What does the average-case running time describe?
- AThe time for an input of average length
- BThe middle value between the best-case and worst-case running times
- CThe expected time over a given distribution of inputs of size n
- DThe time on the most common computer
3.Easy
Which of these running times is polynomial?
- AO(nⁿ)
- BO(2ⁿ)
- CO(n!)
- DO(n³)
4.Medium
How much stack space does a simple recursive factorial function fact(n) = n × fact(n − 1) use?
- AO(log n)
- BO(n)
- CO(n²)
- DO(1)
5.Medium
What is the worst-case time complexity of quicksort?
- AO(n log n)
- BO(log n)
- CO(n)
- DO(n²)
6.Medium
What does amortised analysis measure?
- AThe expected cost over random inputs
- BThe average cost per operation over a worst-case sequence of operations
- CThe cost of an algorithm on the best input
- DThe cost of the single most expensive operation anywhere in the sequence
7.Hard
Which technique gives an expected O(n log n) running time for quicksort on any input?
- AAlways choosing the first element
- BSorting the input before running quicksort
- CUsing recursion only on the left side
- DChoosing the pivot uniformly at random
8.Hard
What is the difference between an undecidable problem and an intractable one?
- AIntractable problems cannot be solved by any algorithm, while undecidable ones only need exponential time
- BUndecidable problems are in NP, while intractable problems are in P
- CAn undecidable problem has no algorithm for all inputs; an intractable one has one, but it is too slow
- DBoth mean the problem has no algorithm at all
Answer key
- 1. C · Quicksort
- 2. C · The expected time over a given distribution of inputs of size n
- 3. D · O(n³)
- 4. B · O(n)
- 5. D · O(n²)
- 6. B · The average cost per operation over a worst-case sequence of operations
- 7. D · Choosing the pivot uniformly at random
- 8. C · An undecidable problem has no algorithm for all inputs; an intractable one has one, but it is too slow
Full step-by-step solutions: practise this topic on examproblems.com.