OCR D1 2013 June — Question 1

Exam BoardOCR
ModuleD1 (Decision Mathematics 1)
Year2013
SessionJune
TopicFixed Point Iteration

1 The list below is to be sorted into increasing order using bubble sort, starting at the left-hand end of the list. $$\begin{array} { l l l l l l } 24 & 57 & 9 & 31 & 16 & 4 \end{array}$$
  1. Show which values are compared and which are swapped in the first pass. Write down the list that results at the end of the first pass.
  2. Without showing the individual comparisons and swaps, write down the lists that result after the second pass and after the third pass.
  3. In total there will be five passes made in carrying out bubble sort on the list. Write down how many swaps are made in each pass.