An algorithm for sorting a list of n numbers into descending order is given below.
The first pass consists of the following. Compare the second value with the first and swap if necessary (that is if the second value is larger than the first).
The second pass consists of the following. Compare the third value with the second and swap if necessary. If a swap happened compare the new second value with the first as in the first pass.
The third pass consists of the following. Compare the fourth value with the third and swap if necessary. If a swap happened compare the new third value with the second as in the second pass.
Continue in this way for n - 1 passes.
Starting at the left-hand end of the list the result after each pass through the above algorithm on the original list of eight numbers is shown below.
| Original list: | 32 | 37 | 25 | 18 | 34 | 27 | 15 | 30 |
| 1st pass: | 37 | 32 | 25 | 18 | 34 | 27 | 15 | 30 |
| 2nd pass: | 37 | 32 | 25 | 18 | 34 | 27 | 15 | 30 |
| 3rd pass: | 37 | 32 | 25 | 18 | 34 | 27 | 15 | 30 |
| 4th pass: | 37 | 34 | 32 | 25 | 18 | 27 | 15 | 30 |
| 5th pass: | 37 | 34 | 32 | 27 | 25 | 18 | 15 | 30 |
| 6th pass: | 37 | 34 | 32 | 27 | 25 | 18 | 15 | 30 |
| 7th pass: | 37 | 34 | 32 | 30 | 27 | 25 | 18 | 15 |
Complete the table in the Printed Answer Booklet showing the number of comparisons and
swaps during each pass through the algorithm.