normalize by half the total, capacity 1, two bins

PARTITION ≤p BIN-PACKING

PARTITION≤pBIN-PACKING\mathrm{PARTITION}\le_p\mathrm{BIN\text{-}PACKING}, so BIN-PACKING\mathrm{BIN\text{-}PACKING} is NP-hard — and stays hard even when the number of bins is the constant k=2k=2.

The construction

The idea: normalize by half the total. A BIN-PACKING\mathrm{BIN\text{-}PACKING} input is numbers in (0,1](0,1] and a bin count kk, asking whether they fit into kk bins each summing to ≤1\le1. Divide each aia_i by half the total and all the numbers sum to exactly 22; then two bins of capacity 11 suffice iff an equal split exists.

The obstacle: some huge aia_i might exceed 11 after normalizing — an invalid output. But if 2ai>T2a_i>T there is no equal split at all, so in that case a fixed string outside the language can be returned.

Algorithm R′R'. On input (a1,…,an)(a_1,\dots,a_n), natural numbers (w.l.o.g. ai>0a_i>0; zeros may be dropped without changing the answer):

  1. Compute T←∑jajT\leftarrow\sum_j a_j.
  2. If some ii has 2ai>T2a_i>T: return (34,34,34, 2)\left(\tfrac34,\tfrac34,\tfrac34,\,2\right).
  3. Otherwise, for each ii set bi←2ai∑jajb_i\leftarrow\dfrac{2a_i}{\sum_j a_j}, and return (b1,…,bn, 2)(b_1,\dots,b_n,\,2).

The key property of the output. At step 3, ∑i=1nbi=∑i2aiT=2T∑iai=2T⋅T=2,\sum_{i=1}^{n}b_i=\sum_i\frac{2a_i}{T}=\frac{2}{T}\sum_i a_i=\frac{2}{T}\cdot T=2 , where pulling 2T\frac2T out is legitimate because it is constant, independent of ii. Also bi>0b_i>0 and bi≤1b_i\le1 (since 2ai≤T2a_i\le T at this step), so bi∈(0,1]b_i\in(0,1] and the output is valid.

On the representation. The bib_i are rationals held as a pair of integers — numerator 2ai2a_i, denominator TT — each of length O(m+log⁡n)O(m+\log n). A BIN-PACKING\mathrm{BIN\text{-}PACKING} input need not be integral; the definition speaks of numbers in (0,1](0,1].

Visualization

Guided construction

Partition → Bin Packing and the 3/2 barrier

Step 1 of 6
A′ = {3, 5, 6, 11, 39, 36}S = 100
Partition mapped to bins of capacity S/2 with the 3/2 ratio rulerItem blocks drawn to scale fill capacity-50 bins flush for the yes-instance and leave shaded slack in three capacity-51 bins for the no-instance, beside a ratio ruler marked 1, 11/9, 3/2, 1.7 and 2.Items drawn to scale356113936
Item block, height proportional to its value

Correctness — both directions

PARTITION ∈ ⟹ BIN-PACKING ∈

Suppose (a1,…,an)∈PARTITION(a_1,\dots,a_n)\in\mathrm{PARTITION}; some II has ∑i∈Iai=∑i∉Iai=T/2\sum_{i\in I}a_i=\sum_{i\notin I}a_i=T/2.

The algorithm reached step 3. Suppose not, i.e. some i0i_0 has 2ai0>T2a_{i_0}>T. The side containing ai0a_{i_0} sums to at least ai0>T/2a_{i_0}>T/2 — contradicting that both sides sum to exactly T/2T/2. So the algorithm did reach step 3.

The packing. Put {bi}i∈I\{b_i\}_{i\in I} in the first bin and {bi}i∉I\{b_i\}_{i\notin I} in the second. The first bin sums to ∑i∈Ibi=2T∑i∈Iai=2T⋅T2=1  ≤  1,\sum_{i\in I}b_i=\frac{2}{T}\sum_{i\in I}a_i=\frac{2}{T}\cdot\frac{T}{2}=1\;\le\;1 , and likewise the second. Both bins respect the capacity and exactly 22 bins were used. So (b1,…,bn,2)∈BIN-PACKING(b_1,\dots,b_n,2)\in\mathrm{BIN\text{-}PACKING}.

BIN-PACKING ∈ ⟹ PARTITION ∈

Suppose the output is in BIN-PACKING\mathrm{BIN\text{-}PACKING}.

Case 1: the algorithm stopped at step 2. Then the output is (34,34,34,2)\left(\tfrac34,\tfrac34,\tfrac34,2\right). Three items of size 34\tfrac34 do not fit into two bins of capacity 11: each bin holds at most one (since 34+34=32>1\tfrac34+\tfrac34=\tfrac32>1), so at least 33 bins are needed. So the output is not in BIN-PACKING\mathrm{BIN\text{-}PACKING} — contradicting the hypothesis. So this case cannot occur and the algorithm reached step 3.

Case 2: the algorithm reached step 3. Then b1,…,bnb_1,\dots,b_n pack into two bins, each summing to ≤1\le1. Let II index those in the first bin. Then ∑i∈Ibi≤1and∑i∉Ibi≤1.\sum_{i\in I}b_i\le1\qquad\text{and}\qquad\sum_{i\notin I}b_i\le1 . But all the bib_i sum to exactly 22, so ∑i∈Ibi=2−∑i∉Ibi  ≥  2−1=1.\sum_{i\in I}b_i=2-\sum_{i\notin I}b_i\;\ge\;2-1=1 . The two inequalities give ∑i∈Ibi=1\sum_{i\in I}b_i=1 exactly, and likewise ∑i∉Ibi=1\sum_{i\notin I}b_i=1.

Translate back: ∑i∈I2aiT=1\sum_{i\in I}\frac{2a_i}{T}=1, i.e. ∑i∈Iai=T2\sum_{i\in I}a_i=\frac{T}{2}, and hence ∑i∉Iai=T−T2=T2\sum_{i\notin I}a_i=T-\frac T2=\frac T2. The two sides are equal, so (a1,…,an)∈PARTITION(a_1,\dots,a_n)\in\mathrm{PARTITION}.

Cost of the reduction

TimeO(|x|²)
SpaceO(|x|)
Output sizeO(|x|)

Computing TT costs O(n(m+log⁡n))O(n(m+\log n)); step 2 is nn comparisons; step 3 is nn writes of the pair (2ai,T)(2a_i,T) — no actual division is needed. Total O(∣x∣2)O(|x|^2), with output length O(∣x∣)O(|x|).

What it buys

BIN-PACKING\mathrm{BIN\text{-}PACKING} is NP-hard — and the same proof gives a bonus: the output always uses k=2k=2, so the problem stays NP-hard with a constant bin count. This is also the starting point for the inapproximability bound: an absolute approximation ratio better than 3/23/2 would distinguish OPT=2\mathrm{OPT}=2 from OPT=3\mathrm{OPT}=3 and hence decide PARTITION\mathrm{PARTITION}.

Pitfalls

  • The test in step 2 must be >>, not ≥\ge. If ai=T/2a_i=T/2 exactly, then {i}\{i\} against its complement is a legal split and the input is in PARTITION\mathrm{PARTITION} — while the step-2 output is not in BIN-PACKING\mathrm{BIN\text{-}PACKING}, and the reduction would break. With >> everything holds, and the boundary case gives bi=1b_i=1, a legal value.

  • Why from PARTITION\mathrm{PARTITION} rather than SUBSET-SUM\mathrm{SUBSET\text{-}SUM}. The nearest-problem principle again: PARTITION\mathrm{PARTITION} has no external target, and neither does BIN-PACKING\mathrm{BIN\text{-}PACKING} — the capacity is dictated internally. Starting from SUBSET-SUM\mathrm{SUBSET\text{-}SUM} would mean baking SS in all over again, work already done.

The chain

Where this was read from

  • Lesson 12משפט 4: PARTITION≤pBIN-PACKING\mathrm{PARTITION} \le_p \mathrm{BIN\text{-}PACKING}
  • Guided exercisebin-packing-approximation
  • 2026"In this question we prove the Bin-PackingBin\text{-}Packing problem seen in class is NPNP-complete."