A student is using a quicksort algorithm to rearrange a set of numbers into ascending order. She uses the first number in each list (or sublist) as the pivot.
Her correct solution for the first three passes is as follows.
Initial list: 10, 7, 4, 22, 13, 16, 19, 5
After 1st pass: 7, 4, 5, 10, 22, 13, 16, 19
After 2nd pass: 4, 5, 7, 10, 13, 16, 19, 22
After 3rd pass: 4, 5, 7, 10, 13, 16, 19, 22
- State the pivots used for the 2nd pass. [2]
- Write down the number of comparisons on each of the three passes. [3]
- Explain whether the student has completed the algorithm. [1]