# 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$$:

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

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

 Item Weight ($kg$) B I A H C D G J E F $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.

The first-fit decreasing algorithm only uses five boxes.