D1 June 2012 Q1

EdexcelOld spec12 marksAlgorithms

1. A carpet fitter needs the following lengths, in metres, of carpet.

20 33 19 24 31 22 27 18 25

He cuts them from rolls of length 50 m.

(a) Calculate a lower bound for the number of rolls he needs.
You must make your method clear. (2)
(b) Use the first-fit bin packing algorithm to determine how these lengths can be cut from rolls of length 50 m. (3)
(c) Carry out a bubble sort to produce a list of the lengths needed in descending order.
You need only give the state of the list after each pass. (4)
(d) Apply the first-fit decreasing bin packing algorithm to show how these lengths may be cut from the rolls. (3)