D1 June 2017 Q3

EdexcelOld spec13 marksAlgorithms

3.

42     21     15     16     35     10     31     11     27     39

(a) Use the first-fit bin packing algorithm to determine how the numbers listed above can be packed into bins of size 65 (3)
(b) The list of numbers is to be sorted into descending order. Use a quick sort to obtain the sorted list. You should show the result of each pass and identify your pivots clearly. (4)
(c) Use the first-fit decreasing bin packing algorithm on your ordered list to pack the numbers into bins of size 65 (3)

The nine distinct numbers below are to be sorted into descending order

23     14     17     \(x\)     21     18     8     20     11

A bubble sort, starting at the left-hand end of the list, is to be used to obtain the sorted list. After the first complete pass, the list is

23     17     \(x\)     21     18     14     20     11     8

After the second complete pass, the list is

23     17     21     18     \(x\)     20     14     11     8

(d) Using this information, write down the smallest interval that must contain \(x\). Give your answer as an inequality. (3)