Question 1
1 markThe array List[1:5] holds the values 6, 2, 9, 4, 1.
State the number of swaps made during the first pass of a bubble sort that sorts List into ascending order.
Model answer
3
Explanation
6 and 2 swap; 6 and 9 are in order; then 9 swaps with 4 and with 1, giving 2, 6, 4, 1, 9. Each comparison uses the array as it is after the previous swap.
Mark scheme
-
1 mark
3