Edexcel D1 2015 June — Question 2

Exam BoardEdexcel
ModuleD1 (Decision Mathematics 1)
Year2015
SessionJune
TopicSorting Algorithms

2. A list of \(n\) numbers needs to be sorted into descending order starting at the left-hand end of the list.
  1. Describe how to carry out the first pass of a bubble sort on the numbers in the list.
    1. State which number in the list is guaranteed to be in the correct final position after the first pass.
    2. Write down the maximum number of passes required to sort a list of \(n\) numbers.
  2. The numbers below are to be sorted into descending order. Use a bubble sort, starting at the left-hand end of the list, to obtain the sorted list. You need only give the state of the list after each pass. $$\begin{array} { l l l l l l l l l } 11 & 9 & 4 & 13 & 5 & 1 & 7 & 12 & 8 \end{array}$$
  3. Apply the first-fit decreasing bin packing algorithm to your ordered list to pack the numbers into bins of size 21