Bin Packing Algorithms
Bin Packing Algorithms
i) Apply the first fit algorithm to the items in the order given and comment on the outcome.
[3]
ii) Write the five items in descending order of volume. Apply the first fit decreasing algorithm to
find a packing for the rucksacks.
[3]
iii) The hikers argue that the first fit decreasing algorithm does not produce a fair allocation of
volumes to rucksacks. Produce a packing which gives a fairer allocation of volumes between
the two rucksacks. Explain why the hikers might not want to use this packing.
[2]
Question 2
650 431 245 643 455 134 710 234 162 452
i) The list of numbers above is to be sorted into descending order. Perform a Quick Sort to
obtain the sorted list, giving the state of the list after each pass, indicating the pivot elements.
[5]
The numbers in the list represent the lengths, in mm, of some pieces of wood. The wood is sold in one
metre lengths.
ii) Use the first-fit decreasing bin-packing algorithm to determine how these pieces could be cut
from the minimum number of one metre lengths. (You should ignore wastage due to cutting.)
[4]
iii) Determine whether your solution to part (ii) is optimal. Give a reason for your answer.
[2]
Question 3
29 52 73 87 74 47 38 61 41
The numbers in the list represent the lengths in minutes of nine radio programmes. They are to be
recorded onto tapes which each store up to 100 minutes of programmes.
i) Obtain a lower bound for the number of tapes needed to store the nine programmes.
[2]
ii) Use the first-fit bin packing algorithm to fit the programmes onto the tapes.
[3]
iii) Use the first-fit decreasing bin packing algorithm to fit the programmes onto the tapes.
[3]
650 432 245 643 455 710 234 162 452 134
650 643 710 455 431 245 234 162 452 134
650 710 643 455 431 452 452 234 162 134
710 650 643 455 431 245 245 234 162 134
710 650 643 455 452 245 245 234 162 134
[5]
ii) Bin 1: 710+245
Bin 2: 650+234
Bin 3: 643+162+134
Bin 4: 455+452
Bin 5: 431
[4]
iii)
4116
=4.116
1000
∴ 5 bins needed
[2]
Question 3
i) = 5.02 so 6 tapes.
[2]
iii) Bin l: 87
Bin 2: 74
Bin 3: 73
Bin 4: 61, 38
Bin 5: 52, 47
Bin 6: 41, 29
[3]