Quicksort and selection
1.[2p] Lomuto partitioning of an array of 8 elements makes how many comparisons?
Lomuto partitioning of an array of 8 elements makes how many comparisons?
2.[3p] A textbook quicksort that always takes the last element as pivot is quadratic on
A textbook quicksort that always takes the last element as pivot is quadratic on
3.[3p] Using with , how many comparisons does quicksort average on 1000 elements?
Using with , how many comparisons does quicksort average on 1000 elements?
4.[3p] Quicksort averages about 39 per cent more comparisons than mergesort's worst case and is still usually faster because
Quicksort averages about 39 per cent more comparisons than mergesort's worst case and is still usually faster because
5.[3p] Choosing the pivot uniformly at random changes the analysis because
Choosing the pivot uniformly at random changes the analysis because
6.[2p] Median-of-three pivot selection guarantees that quicksort avoids its quadratic case.
Median-of-three pivot selection guarantees that quicksort avoids its quadratic case.
7.[2p] Introsort achieves a worst-case bound by
Introsort achieves a worst-case bound by
8.[3p] Quickselect is on average rather than because
Quickselect is on average rather than because
9.[3p] Match each algorithm to its worst-case cost.
Match each algorithm to its worst-case cost.
Mergesort
Randomised quicksort
Introsort
Median-of-medians selection
Show the answer
Mergesort: Randomised quicksort: Introsort: Median-of-medians selection: