Question 1 Report
Fig. 1 shows test data from a drone survey. The computer must arrange image file sizes in ascending order before uploading them over a network. The diagram compares the number of adjacent comparisons made by bubble sort in successive passes. The final pass has no red swap arrows.
(a) State the sorted array shown at the end of Fig. 1. [1]
(b) Give the total number of swaps shown. [2]
(c) State the pass on which an optimised bubble sort can stop. [1]
(d) Explain why no further pass is needed at this point. [2]
(e) Give the maximum number of comparisons an unoptimised bubble sort makes when sorting five values. [3]
Bubble sort repeatedly compares adjacent values. For ascending order, a pair is swapped when the left value is larger than the right value.
Everything you need to excel in your exams