📄 Key points & how to fill in the pro forma
1swapMade = TRUE, numComparisons = sizeOfList − 1
2Each pass: compare i = 0 … numComparisons−1, swap when out of order and set swapMade
3End of pass: Decrement numComparisons (the settled maximum needs no more checks)
4A pass with no swap (swapMade = FALSE) → the WHILE ends, the sort is done
5Hand in: one row per pass with the whole array, plus the two totals at the bottom
How do I fill in the pro forma? One row = one pass: copy the whole 16-name array as it stands after that pass. Then put the total comparisons in the bottom-left box and the total swaps in the middle box. Every row of the table on this page can be copied straight over — the “Copy the table” button even copies it as TSV for Word/Excel.
Why one comparison fewer each pass? At the end of a pass the largest element has been pushed to the end of the unsorted part — it is already in place, so it never needs checking again, hence numComparisons is decremented.
Two optimisations: (1) swapMade stops early on data that is already sorted (best case: 1 pass, 15 comparisons); (2) decrementing numComparisons saves one comparison per pass, bringing the total down from n² to n(n−1)/2.
This data set: 13 passes · 117 comparisons · 87 swaps; during pass 13 swapMade stays FALSE, so the loop ends.
Stability: only a strict inversion (>) swaps, so equal values never cross → bubble sort is stable.