Bin Packing: Lower Bounds, First Fit, First Fit Decreasing and Full Bins | Edexcel IAL Maths notes
Free preview: Bin Packing: Lower Bounds, First Fit, First Fit Decreasing and Full Bins
Bin Packing and the Lower Bound
Unit D1 (WDM11): Decision Mathematics 1
Let's start with a real job. A removal firm has boxes of different masses and crates that each hold 20 kg. Every crate costs money to move. How few crates can it use?
- The bin packing problem: pack items of given sizes into bins of the same capacity, using as few bins as possible.
- The "bins" can be anything: crates, lorries, CDs filled with songs, time slots filled with jobs, lengths of wood cut into pieces.
- No item can be split, and no bin can go over its capacity.
- For big problems there is no known quick algorithm that always finds the best packing, so we use heuristics: quick methods that give good, but not always best, packings (you met this word in the first note on algorithms).
Our example
- Nine boxes, masses in kg: A 11, B 8, C 7, D 5, E 4, F 12, G 7, H 9, I 13.
- Crate capacity: 20 kg.
Before packing anything, let's ask: what is the fewest crates we could possibly need? That number is called a lower bound.
Step 1: the lower bound
- A lower bound is a number the answer cannot be smaller than.
- However cleverly we pack, the crates must hold the total mass.
- Total: kg.
- The symbol means round up to the next whole number (if it is already whole, leave it).
- Here , so the lower bound is 4 crates.
- Why round up? 3 crates hold at most 60 kg, which is not enough, so we need at least 4.

What the picture shows
- The items total 76 kg and each crate holds 20 kg, so .
- Wrong: rounding down to 3 leaves 16 kg with nowhere to go, because 3 crates hold only 60 kg.
- Right: always round a lower bound UP. 3.8 tells you 3 is not enough, so at least 4 crates are needed.
๐ก In plain words
- The lower bound is the number of bins you would need if you could pour the items in like water.
- No packing can use fewer bins than this. If a packing uses exactly this many, it must be optimal (the best possible).
๐ Show the division
Write ", so at least 4 bins". The calculation and the rounding up each earn credit. Never round down: 3.8 bins means 3 are not enough.
โ๏ธ YOUR TURN 1
Try this first:
Seven parcels of sizes 6, 9, 4, 7, 3, 8 and 5 units go into containers of capacity 15. Find a lower bound for the number of containers.
Answer:
- Total: .
- , so at least 3 containers.
- Check: 2 containers hold only 30, which is less than 42.
โ๏ธ YOUR TURN 2
Try this first:
Items of size 12, 18, 10 and 20 are to be packed into bins of capacity 15. What is wrong with this problem, before you even work out a lower bound?
Answer:
The item of 18 and the item of 20 are bigger than a bin, so they cannot be packed at all. Always check that every item is at most the capacity. (If they could be packed, the formula would give .)
The First Fit Algorithm
Now let's actually pack. The simplest sensible rule: take each item as it comes and drop it in the first crate that has room. That is first fit.
The first fit recipe
- Take the items in the order given. Why: first fit makes no attempt to rearrange; that is what makes it quick.
- Put each item into the first bin (bin 1, then bin 2, and so on) that has enough room left for it. Why: earlier bins get topped up before we open new ones.
- If no bin has room, start a new bin.
- Every new item starts checking from bin 1 again. Why: a small item may still squeeze into an early bin.
๐ Watch me do it: first fit on the crates (capacity 20)
| What I write | Why I do it |
|---|---|
| A = 11 into bin 1 (11) | No bins yet, so open bin 1. |
| B = 8 into bin 1 (19) | 11 + 8 = 19, which is at most 20. |
| C = 7 into bin 2 (7) | Bin 1: 19 + 7 = 26, too much. Open bin 2. |
| D = 5 into bin 2 (12), E = 4 into bin 2 (16) | Each time bin 1 is checked first and is too full (19 + 5 = 24, 19 + 4 = 23). |
| F = 12 into bin 3 (12) | Bin 1 is at 19, bin 2 at 16: neither has room for 12. |
| G = 7 into bin 3 (19) | Bin 1: 26, bin 2: 23, both too much. Bin 3: 12 + 7 = 19. |
| H = 9 into bin 4 (9) | Bins are at 19, 16, 19, so none has room for 9. |
| I = 13 into bin 5 (13) | Does not fit with H (22), or anywhere else. |
| First fit uses 5 bins | Bin 1: A, B. Bin 2: C, D, E. Bin 3: F, G. Bin 4: H. Bin 5: I. |
Unlock the full note: start 7 days free.
Log in or subscribe to read the rest of this note. Members also get the AI tutor, practice quizzes, mock exams and flashcards for this topic.
Log in ยท Subscribe ยท Start free trial
All notes in D1.1 Algorithms, Sorting, Searching and Packing
- What Is an Algorithm? Flow Charts, Pseudocode and Trace Tables
- Bubble Sort and Quick Sort Step by Step
- Binary Search: Halving an Ordered List
- Bin Packing: Lower Bounds, First Fit, First Fit Decreasing and Full Bins
What's inside for this topic
4 teacher notes, 103 practice questions, 38 flashcards, 2 quizzes.
Get the full notes, every practice question, flashcards, quizzes and mock papers.
Previous note: Binary Search: Halving an Ordered List