A bubble sort is used to put this list into ascending order:
[7, 3, 9, 1, 5](a) Show the list after the first pass of the bubble sort. [2]
(b) State how many swaps are made during the first pass. [1]
(c) Explain how the bubble sort algorithm knows that the list is fully sorted. [1]
- (a) 9 is in the last position(1)
- (a) Whole list correct: [3, 7, 1, 5, 9](1)
- (b) 3(1)
- (c) A complete pass is made with no swaps (accept: after n − 1 passes, where n is the number of items)(1)
- Answer: (a) [3, 7, 1, 5, 9] (b) 3 (c) a pass is completed with no swaps
- Examiner tip: A pass compares every adjacent pair once. Do not stop after the first swap.