D1 June 2018 Q2

EdexcelOld spec12 marksAlgorithms

2. A list of nine numbers needs to be sorted into descending order.

(a) Describe how to carry out the first pass of a bubble sort on the numbers in the list. (2)

Mayleen used a sorting algorithm to sort a list of nine numbers into descending order.

Mayleen’s list after the first pass through the algorithm is given below.

30     33     35     27     20     24     21     15     19

(b) Explain how you know that Mayleen did not use the bubble sort algorithm. (2)

Given that Mayleen used the quick sort algorithm,

(c) write down the number that was used as a pivot for the first pass, (1)
(d) complete the quick sort to obtain a fully sorted list in descending order. You must make your pivots clear. (3)
(e) Use the first-fit decreasing bin packing algorithm to determine how the numbers listed can be packed into bins of size 60 (3)

A tenth number, 18, is added to the list of nine numbers.

(f) Determine whether it is possible to pack the ten numbers into 4 bins of size 60.
You must justify your answer. (1)