91热爆

Container packing

National 4 container packing looks at First-fit algorithm in particular.

For National 5 the aim is to minimise the amount of containers used.

There is no set way of doing this but one method is described below.

First- fit decreasing algorithm

The following items to be packed into boxes that can hold up to \(10kg\):

ItemABCDEFGHIJ
Weight (\(kg\))\(7\)\(8\)\(4\)\(4\)\(2\)\(2\)\(3\)\(5\)\(8\)\(3\)
Item
A
B
C
D
E
F
G
H
I
J
Weight (\(kg\))
\(7\)
\(8\)
\(4\)
\(4\)
\(2\)
\(2\)
\(3\)
\(5\)
\(8\)
\(3\)

The first-fit decreasing algorithm puts the items in order of heaviest to lightest.

ItemBIAHCDGJEF
Weight (\(kg\))\(8\)\(8\)\(7\)\(5\)\(4\)\(4\)\(3\)\(3\)\(2\)\(2\)
Item
B
I
A
H
C
D
G
J
E
F
Weight (\(kg\))
\(8\)
\(8\)
\(7\)
\(5\)
\(4\)
\(4\)
\(3\)
\(3\)
\(2\)
\(2\)

Now continue as you would with the first-fit algorithm by putting each item into the first container that has room for it.

An algorithm to show how available sections fit into boxes
Figure caption,
The first-fit decreasing algorithm only uses five boxes.

Related links