A gym worker is tidying up by stacking weights on shelves. The weights, given in kilograms, are stated below.
12, 16, 18, 8, 16, 12, 10, 4, 6, 10, 12, 16, 20, 10, 24
Each shelf has a load capacity of 40 kg.
a)
Find a lower bound for the number of shelves needed so all the weights can be stacked on the shelves.
The lower bound will be (greater than or equal to) the total of the weights divided by the capacity (load) of one shelf
The number of shelves (bins) will need to be an integer (hence the inequality)
More than four shelves are needed so round up to five
Lower bound for the number of shelves is 5
b)
Use the first-fit bin packing algorithm to find the number of shelves needed to stack all of the weights.
In this case, a 'shelf' will be a 'bin'
In the first-fit bin packing algorithm, we deal with each weight in turn as they are listed
(The remaining capacity, written in brackets next to each shelf in the working area, is optional)
The first weight, 12 kg, will go on the first shelf
The second weight, 16 kg will also fit on the first shelf
Next, the 18 kg will need to go on to a new shelf (shelf 2)
Shelf 1: |
12 |
16 |
|
|
|
[12] |
Shelf 2: |
18 |
|
|
|
|
[22] |
The 8 kg weight will go on the first shelf
Shelf 1: |
12 |
16 |
8 |
|
|
[4] |
Shelf 2: |
18 |
|
|
|
|
[22] |
Continuing in this manner, the 16 kg weight can go on shelf 2
The second 12 kg weight will need a third shelf
Shelf 1: |
12 |
16 |
8 |
|
|
[4] |
Shelf 2: |
18 |
16 |
|
|
|
[6] |
Shelf 3: |
12 |
|
|
|
|
[28] |
A fourth shelf is needed for the third 12 kg weight
The 20 kg and 24 kg weights require a shelf of their own
When finished, double check each shelf does not exceed 40 kg in total
Do not include the spare capacities with the final answer
Shelf 1: |
12 |
16 |
8 |
4 |
Shelf 2: |
18 |
16 |
6 |
|
Shelf 3: |
12 |
10 |
10 |
|
Shelf 4: |
12 |
16 |
10 |
|
Shelf 5: |
20 |
|
|
|
Shelf 6: |
24 |
|
|
|
Notice that, whilst the lower bound was 5 shelves, the algorithm used 6 shelves