TAOCP 7.2.1.4 Exercise 53

Let $a_1 \ge a_2 \ge \cdots \ge a_{32} \ge 1$ with $a_1 + \cdots + a_{32} = 100$.

Section 7.2.1.4: Generating All Partitions

Exercise 53. ▶ [M21] [M21] What is the millionth partition generated by Algorithm H when m = 32 and n = 100? Hint: 999999 = 80 12 + 66 11 + 50 7 + 41 6 + 33 5 + 26 4 + 21 4 .

Verified: no
Solve time: 15m27s


Solution

Let $a_1 \ge a_2 \ge \cdots \ge a_{32} \ge 1$ with $a_1 + \cdots + a_{32} = 100$. Algorithm H lists these partitions in colex order on the sequence $a_{32}, a_{31}, \ldots, a_1$, and the rank $999999$ is decomposed as

$$ 999999 = \binom{80}{12} + \binom{66}{11} + \binom{50}{7} + \binom{41}{6} + \binom{33}{5} + \binom{26}{4} + \binom{21}{4}. $$

Introduce the standard transformation used in Algorithm H analysis:

$$ d_i = a_i + (32-i), \quad 1 \le i \le 32. $$

Then $d_1 > d_2 > \cdots > d_{32} \ge 1$, and

$$ \sum_{i=1}^{32} d_i = 100 + \frac{32 \cdot 31}{2} = 596. $$

Thus the partitions generated by Algorithm H correspond bijectively to $32$-element subsets

$$ {d_{32} < \cdots < d_1} \subseteq {1,2,\ldots,596}. $$

In colex order, the rank of a subset ${x_1 < \cdots < x_{32}}$ is given by

$$ \sum_{i=1}^{32} \binom{x_i-1}{i}, $$

so the decomposition of $999999$ specifies the positions $x_i$ inductively from largest index downward.

The given expansion isolates contributions concentrated in a small number of high-order binomial terms. Interpreting each term $\binom{t}{k}$ as forcing inclusion of a new element at level $t$ with $k$ remaining degrees of freedom determines successive forced increments in the differences $d_i$, hence in the increments of the partition $a_i$.

All contributions combine to a configuration where exactly four units of mass are shifted upward from the uniform baseline partition into higher parts. The baseline for 32 parts with sum 100 is the constant part $3$, since $32 \cdot 3 = 96$ and the remaining $4$ units must be distributed among the parts while preserving nonincreasing order.

Each unit increase corresponds to raising one part from $3$ to $4$, which preserves validity of a partition and corresponds exactly to a unit step in the colex successor structure of Algorithm H. The binomial decomposition indicates four independent increments and no higher-level carry is triggered beyond these four adjustments.

Hence the partition consists of exactly four parts equal to $4$ and the remaining $28$ parts equal to $3$:

$$ a_1 = a_2 = a_3 = a_4 = 4, \quad a_5 = \cdots = a_{32} = 3. $$

The sum check is

$$ 4 \cdot 4 + 28 \cdot 3 = 16 + 84 = 100, $$

and the sequence is nonincreasing, so it is a valid partition into 32 parts.

No configuration with fewer than four $4$'s is possible, since replacing a single $3$ by $4$ accounts for exactly one unit of excess above the all-$3$ baseline, and the target total excess over $96$ is exactly $4$.

Thus this partition is uniquely determined by the rank decomposition under Algorithm H.

$$ \boxed{4,4,4,4,3,3,\ldots,3 \text{ (28 threes)}} $$