You are on page 1of 10

Bin Packing

First fit algorithm

A B C D E F
Each block will be fitted into the first bin that has room for it.

5 6
4 3 3 3
2 2
1
Bin Packing
First fit algorithm

A B C D E F
The first block fits into the first bin

5 6
2 3 2 3 3
1
Bin Packing
First fit algorithm
1

A B C D E F
The second block fits in the first bin

5 6
2 3 2 3 3
Bin Packing
First fit algorithm
2
1

4
2

A B C D E F
The
But
third
there
block
is room
will not
in the
fit in
second
the first
binbin

5 6
3 2 3 3
Bin Packing
5 First fit algorithm
1 5
5
4
2

A B C D E F
The third bin is the first one the 5 will fit in

6
3 2 3 3
Bin Packing
First fit algorithm
3
1
3
5
4
2

A B C D E F
The second bin has room for the 3

6
2 3 3
Bin Packing
First fit algorithm
2 2 2
1
3
5
4
2 2

A B C D E F
The fourth bin is the first one with room for
the next one

6
3 3
Bin Packing
First fit algorithm
3 3 3
1
3 3
5
4
2 2

A B C D E F
The next one also fits in the fourth bin

6
3
Bin Packing
6 First
6 fit
6 algorithm
6

1
3 3 6
5
4
2 2

A B C D E F
No room until the fifth bin for the 6

3
Bin Packing
First fit algorithm
3
3 3 3 3
1
3 3 6
5
4 3
2 2

A B C D E F
TheTotal
3 hasusage
to start
is 6a bins.
new bin

You might also like