Back to Combinatorics

Chapter 4: Permutations and Combinations

October 10, 2026 Wasil Zafar 24 min read

Count arrangements, allocations, functions, and constrained words

Table of Contents

  1. Foundational principles: the fundamental rules of counting
  2. Permutations and combinations of sets
  3. Permutations and combinations of multisets
  4. Strings over finite alphabets
  5. Stars and bars, with upper and lower bounds
  6. Counting functions: injections, surjections, and bijections
  7. Balls into bins: distinguishable and indistinguishable objects
  8. How many allocations satisfy all capacity constraints?
  9. Finite probability applications
  10. Occupancy problems: multinomial distributions
  11. Counting binary strings and constrained words
  12. Choose the right model for balls, bins, and words

Foundational Principles: The Fundamental Rules of Counting

Before tackling complex capacity constraints and allocations, every combinatorial problem relies on two foundational principles: the Multiplication Principle (Rule of Product) and the Addition Principle (Rule of Sum). Understanding when to multiply and when to add forms the bedrock of discrete mathematics.

The Multiplication Principle (Rule of Product)

If a procedure consists of $k$ sequential steps, where the 1st step can be performed in $n_1$ ways, the 2nd step in $n_2$ ways, and so on up to the $k$-th step in $n_k$ ways, then the total number of ways to complete the entire procedure is the product:

$$\text{Total Ways} = n_1 \times n_2 \times \cdots \times n_k$$
1. Sequential Actions

Use the product rule when choices occur in sequence or stage-by-stage (performing Action $A$ AND THEN Action $B$).

2. Consistent Branch Counts

For the simple product rule, each partial choice has the same number of continuations at the next stage. If branch counts vary, count each complete branch and add the results.

3. Addition vs. Multiplication

Multiply for sequential steps ($A$ and $B$). Add for mutually exclusive options ($A$ or $B$, giving $a + b$ ways).

Multiplication Principle Decision Tree Diagram Decision tree illustrating 3 main courses branching into 4 desserts each, yielding 3 x 4 = 12 total complete meal combinations. Multiplication Principle: Restaurant Meal Choices ($3 \times 4 = 12$ Meals) Start Main 1 (Steak) Main 2 (Salmon) Main 3 (Pasta) 4 Desserts Each: Cake, Pie, Ice Cream, Fruit ➔ 4 Combinations 4 Desserts Choice ➔ 4 Combinations 4 Desserts Choice ➔ 4 Combinations Total Meal Options 3 × 4 = 12 Meals
Figure 4.1: Each of the 3 main courses splits into 4 independent dessert choices, multiplying to $3 \times 4 = 12$ distinct meal outcomes.

Common Applications of the Multiplication Principle

Outfits
Wardrobe Combinations

Choosing from 5 shirts and 3 pants yields $5 \times 3 = 15$ complete outfits.

Security
Passwords & PIN Codes

A 4-digit PIN with digits 0–9 yields $10 \times 10 \times 10 \times 10 = 10^4 = 10,000$ codes.

Arrangements
Sequential Factorials ($n!$)

Arranging $n$ distinct items in a row uses descending choices: $n \times (n-1) \times \cdots \times 1 = n!$.

Product Rule vs Sum Rule Visual Comparison Diagram comparing the Multiplication Rule (sequential steps) and Addition Rule (mutually exclusive alternatives). Rule Matrix: When to Multiply vs. When to Add MULTIPLICATION RULE (Sequential Steps) Condition: Action A AND THEN Action B Formula: Total = a × b Example: 5 Shirts AND 3 Pants 5 × 3 = 15 Complete Outfits ADDITION RULE (Mutually Exclusive) Condition: Choice A OR Choice B (Cannot do both) Formula: Total = a + b Example: Travel by 3 Trains OR 2 Buses 3 + 2 = 5 Travel Options
Figure 4.2: Sequential combinations require multiplication, while mutually exclusive alternatives require addition.

Permutations and Combinations of Sets

Combinatorics begins by clarifying two fundamental conditions of choice: whether the order of selection matters and whether selection occurs with or without replacement. Given a set of four distinct objects $\{A, B, C, D\}$, choosing two objects in order without replacement produces $12$ ordered pairs such as $AB$ and $BA$. Choosing an unordered pair without replacement produces $6$ unique subsets such as $\{A, B\}$.

Fundamental Counting Formulas for Selection Without Replacement

When elements are chosen without replacement (each object can be selected at most once), the number of ways to arrange or select $r$ items from $n$ distinct objects ($0 \le r \le n$) is:

  • Factorial ($n!$): Full permutations of $n$ distinct items in a row: $n! = n(n-1)\cdots 2 \cdot 1$, with $0! = 1$.
  • $r$-Permutations ($P(n,r)$): Ordered selection of $r$ elements out of $n$ without replacement: $$P(n,r) = n(n-1)\cdots(n-r+1) = \frac{n!}{(n-r)!}$$
  • $r$-Combinations ($\binom{n}{r}$): Unordered selection of $r$ elements (subsets) without replacement: $$\binom{n}{r} = \frac{P(n,r)}{r!} = \frac{n!}{r!(n-r)!}$$

Why Divide by $r!$? When order is ignored, every $r$-element subset generates exactly $r!$ distinct ordered sequences. Dividing the total ordered count $P(n,r)$ by $r!$ collapses permutations into equivalence classes of size $r!$, where each class corresponds to a single unique subset.

Why the Permutation and Combination Formulas Work

Counting ordered selections

To build an ordered selection of $r$ different objects from $n$, fill its positions one at a time. There are $n$ choices for the first position, $n-1$ for the second, and so on. After $r-1$ objects have been used, there are $n-r+1$ choices for the last position. By the multiplication principle,

$$P(n,r)=n(n-1)\cdots(n-r+1).$$

Using $n! = n(n-1)\cdots 1$ and the convention $0! = 1$, split the factors of $n!$ after the first $r$ factors:

$$n! = P(n,r)(n-r)! \qquad\Longrightarrow\qquad P(n,r)=\frac{n!}{(n-r)!}.$$

When $r=0$, there is one way to choose no objects—the empty selection—so $P(n,0)=1$, which agrees with the formula. When $r=n$, this gives $P(n,n)=n!$, the number of ways to arrange all $n$ objects.

Counting unordered selections

We can make an ordered selection in two steps: first choose which $r$ objects to use, then arrange those chosen objects. There are $\binom{n}{r}$ ways to do the first step and $r!$ ways to do the second. Every ordered selection comes from exactly one such choice-and-arrangement pair, so

$$P(n,r)=\binom{n}{r}r! \qquad\Longrightarrow\qquad \binom{n}{r}=\frac{P(n,r)}{r!}=\frac{n!}{r!(n-r)!}.$$

In short: permutations count the chosen objects and their order; combinations count only which objects were chosen.

Ordered Permutations vs Unordered Combinations Visualizer Diagram showing how selecting 2 items from {A,B,C,D} gives 12 ordered permutations that collapse into 6 unordered subsets by dividing by 2!. Ordered Selections $P(4,2) = 12$ vs. Unordered Subsets $\binom{4}{2} = 6$ Ordered Pairs $P(4,2) = 12$ AB, BA AC, CA AD, DA BC, CB BD, DB CD, DC Order Matters: AB ≠ BA ÷ 2! Collapse Unordered Subsets $\binom{4}{2} = 6$ {A, B} {A, C} {A, D} {B, C} {B, D} {C, D} Order Ignored: {A, B} = {B, A}
Figure 4.3: Dividing ordered selections by $r! = 2!$ merges symmetric pairs into unique unordered subsets.

The Core Distinction: Selection With vs. Without Replacement

To master counting problems, we must explicitly distinguish between sampling without replacement and sampling with replacement:

  • Without Replacement: Once an object is chosen from the pool, it is removed and cannot be selected again. The pool size shrinks by $1$ after each draw ($n, n-1, n-2, \dots$). This models assignments where no element can occupy two positions simultaneously (e.g., elected officer roles, drawing cards from a deck).
  • With Replacement: After an object is chosen, it is inspected and returned to the pool. The pool size remains constant ($n$) for every single selection. This allows the exact same item to be selected multiple times (e.g., rolling dice, generating passcode digits, assigning independent treatment plans).
Selection Condition Ordered Selections (Sequences / Lists) Unordered Selections (Subsets / Groups)
Without Replacement
(Objects used at most once)
Permutations $P(n,r)$
$$\frac{n!}{(n-r)!}$$

e.g., President, VP, Treasurer from 10 people

Combinations $\binom{n}{r}$
$$\frac{n!}{r!(n-r)!}$$

e.g., Committee of 3 from 10 people

With Replacement
(Objects can repeat)
Tuples / Sequences
$$n^r$$

e.g., $r$-digit PIN numbers, assigning 10 patients to 3 treatments

Multisets (Stars & Bars)
$$\binom{n+r-1}{r}$$

e.g., Selecting $r$ identical scoops from $n$ ice cream flavors


Combinations via Binary String Encoding (Choose vs. Reject)

A powerful intuitive model for understanding combinations comes from encoding subset selections as binary string decisions. Suppose we have a set of $n = 5$ named individuals: John, Mary, David, Sarah, and James ($N = \{1, 2, 3, 4, 5\}$), and we wish to choose an unordered committee of $r = 3$ people.

Instead of picking individuals one by one, set up $5$ ordered slots representing the $5$ candidates in fixed order. For each slot, assign either a "C" (Choose) or an "R" (Reject) label:

String C C C R R

Choose #1 (John), Choose #2 (Mary), Choose #3 (David), Reject #4 (Sarah), Reject #5 (James) $\implies$ Committee: {John, Mary, David}.

String R C C R C

Reject #1, Choose #2 (Mary), Choose #3 (David), Reject #4, Choose #5 (James) $\implies$ Committee: {Mary, David, James}.

Every possible committee of size $r = 3$ maps bijectively to a 5-letter word consisting of exactly $3$ copies of symbol C and $2$ copies of symbol R. The number of distinct arrangements of this multiset word is given by the multinomial coefficient:

$$\binom{n}{r} = \frac{n!}{\underbrace{r!}_{\text{overcount of C's}} \times \underbrace{(n-r)!}_{\text{overcount of R's}}}$$
Choose vs Reject String Encoding Visualizer Diagram showing how selecting 3 people out of 5 corresponds to arrangements of a 5-letter word with 3 Cs and 2 Rs. Combinations as Multiset Permutations: Choose (C) vs. Reject (R) 1. John C 2. Mary C 3. David C 4. Sarah R 5. James R 5-Letter Word "CCCRR" Arrangements = 5! / (3! × 2!) = 10 Unique Committees
Figure 4.4: Every choice of $r = 3$ elements out of $n = 5$ corresponds directly to permuting a word with 3 'C's and 2 'R's.

Symmetry Identity ($\binom{n}{r} = \binom{n}{n-r}$): This binary string perspective makes complementary symmetry glaringly obvious. Selecting $r$ elements to include (choosing $r$ "C"s) forces $n-r$ elements to be excluded (choosing $n-r$ "R"s). Swapping the role of "Choose" and "Reject" leaves the denominator $r! (n-r)!$ completely unchanged:

$$\binom{n}{r} = \frac{n!}{r!(n-r)!} = \frac{n!}{(n-r)!(n-(n-r))!} = \binom{n}{n-r}$$

We can count all subsets in two ways. First, each of the $n$ elements has two independent choices: include it or leave it out. By the multiplication principle, this gives $2 \times 2 \times \cdots \times 2 = 2^n$ subsets. Alternatively, group the subsets by their size: there are $\binom{n}{r}$ subsets containing exactly $r$ elements. Since every subset has exactly one size from $0$ through $n$, adding these groups counts every subset exactly once:

$$\begin{aligned} \sum_{r=0}^{n} \binom{n}{r} &= \binom{n}{0} + \binom{n}{1} + \binom{n}{2} + \cdots + \binom{n}{n-1} + \binom{n}{n} \\ &= 2^n. \end{aligned}$$

Two Perspectives on Selection and Arrangement

When solving problems that involve both selecting elements and ordering them without replacement, there are two equivalent conceptual workflows:

Perspective 1: Direct Sequential Filling

Fill $r$ ordered slots directly one by one:

First slot has $n$ choices, second has $n-1$, up to $r$-th slot with $n-r+1$ choices: $$P(n,r) = n \times (n-1) \times \dots \times (n-r+1)$$

Perspective 2: Two-Step Selection then Shuffle

First choose $r$ unordered elements, then arrange them:

Step 1: Choose $r$ items in $\binom{n}{r}$ ways. Step 2: Order those $r$ items across $r$ positions in $r!$ ways: $$P(n,r) = \binom{n}{r} \times r!$$

Worked Example: Seating 4 People at a 4-Seat Table from 10 Candidates

Suppose 10 people are available, and 4 must be chosen to sit in 4 labeled seats around a table. How many seating arrangements exist?

  • Method 1 (Direct Permutation): Fill seat 1 ($10$ options), seat 2 ($9$ options), seat 3 ($8$ options), seat 4 ($7$ options): $$10 \times 9 \times 8 \times 7 = \mathbf{5040} \text{ arrangements}$$
  • Method 2 (Two-Step Choose & Arrange): First choose 4 people ($\binom{10}{4} = 210$), then arrange those 4 chosen people in $4! = 24$ orderings: $$\binom{10}{4} \times 4! = 210 \times 24 = \mathbf{5040} \text{ arrangements}$$

Both methods yield the exact same answer! Choose whichever perspective best aligns with the problem statement.


Constrained Permutations: The Block Strategy

When arranging items with grouping requirements (e.g., keeping related items adjacent), use the Block Strategy: treat each required cluster of adjacent items as a single macro-element ("block"), arrange the blocks, and then multiply by the internal permutations within each block.

Worked Example

Arranging 10 Distinguishable Books on a Shelf

Suppose you have $10$ distinct books: 5 Mathematics, 3 History, and 2 Art books.

Scenario A: Pick and Line Up Any 3 Books

How many ways can you select and arrange 3 books from the 10 on a shelf?

$$P(10,3) = 10 \times 9 \times 8 = \mathbf{720} \text{ ways}$$
Scenario B: Arrange All 10 Books by Subject

All books of the same subject must be kept together in adjacent blocks.

$$3! \times (5! \times 3! \times 2!) = \mathbf{8640} \text{ ways}$$
Detailed Breakdown for Scenario B (Block Strategy):
  1. Block Level Arrangements ($3!$): There are 3 subject blocks (Math, History, Art). These 3 macro-blocks can be arranged on the shelf in $3! = 6$ orders (e.g., Math-Art-History, Art-Math-History, etc.).
  2. Internal Block Arrangements:
    • $5$ Math books arranged internally in $5! = 120$ ways.
    • $3$ History books arranged internally in $3! = 6$ ways.
    • $2$ Art books arranged internally in $2! = 2$ ways.
  3. Apply Multiplication Principle: $$\text{Total Ways} = \underbrace{3!}_{\text{Block Order}} \times \underbrace{5!}_{\text{Math}} \times \underbrace{3!}_{\text{History}} \times \underbrace{2!}_{\text{Art}} = 6 \times 120 \times 6 \times 2 = \mathbf{8,640}$$
Block Strategy Permutation Visualizer Diagram showing 10 books grouped into 3 subject blocks (Math, Art, History) illustrating macro-block permutations multiplied by internal book permutations. The Block Strategy: Macro-Block Permutations × Internal Permutations Block 1: Math (5 Books) M1 M2 M3 M4 M5 Internal: 5! = 120 Block 2: Art (2) A1 A2 Internal: 2! = 2 Block 3: History (3) H1 H2 H3 Internal: 3! = 6 Total = (3 Block Orderings) × (5! Math) × (2! Art) × (3! History) = 6 × 120 × 2 × 6 = 8,640
Figure 4.5: Bundling elements into blocks simplifies complex constrained arrangements into macro-level and micro-level product counts.

Permutations and Combinations of Multisets

A multiset is a collection where objects are allowed to repeat with specific multiplicities. In the multiset $\{A, A, B\}$, the two copies of $A$ are completely indistinguishable. Its distinct linear arrangements are $AAB$, $ABA$, and $BAA$—yielding 3 unique outcomes rather than $3! = 6$.

Proof Workshop

Multiset Permutations: The Word BANANA

Problem: Calculate the distinct arrangements of the letters in BANANA. Then count how many arrangements begin and end with $A$.

  • Total Word Length: $n = 6$ letters, with multiplicities $n_A = 3$, $n_N = 2$, $n_B = 1$.
  • Total Distinct Permutations: $$\frac{6!}{3! \, 2! \, 1!} = \frac{720}{6 \times 2 \times 1} = 60$$
  • Constrained Case (A at both ends): Fixing $A$ at position 1 and position 6 leaves 4 interior positions to be filled by the remaining multiset $\{A: 1, N: 2, B: 1\}$: $$\frac{4!}{1! \, 2! \, 1!} = \frac{24}{2} = 12 \text{ arrangements}$$
Multiset Permutation Collapse for BANANA Diagram showing 6! = 720 labeled permutations collapsing down to 60 distinct words by dividing out duplicate letter permutations 3! for A and 2! for N. Permuting the Multiset $\{A:3, N:2, B:1\}$ (Word BANANA) Labeled Letters 6! = 720 Arrangements ÷ (3! × 2!) Visible Distinct Words 6! / (3! 2! 1!) = 60 Words Overcount Factor: 3! = 6 orderings of $A_1, A_2, A_3$ and 2! = 2 orderings of $N_1, N_2$ map to the same word
Figure 4.6: Dividing full labeled permutations ($6!$) by duplicate letter internal orderings ($3! 2!$) recovers the exact count of unique multiset words.

Strings Over Finite Alphabets

An alphabet $\Sigma$ is a finite set of symbols. A string (or word) of length $n$ over $\Sigma$ is an ordered sequence $(w_1, w_2, \dots, w_n)$ where $w_i \in \Sigma$. If $|\Sigma| = q$, the product rule implies there are $|\Sigma^n| = q^n$ possible words of length $n$.

A bijection is a one-to-one correspondence between two sets: every element on either side matches exactly one element on the other. A bijection proves that the sets have the same size, so counting either set gives the count for both.

For a binary alphabet $\Sigma = \{0, 1\}$, the weight of a string is defined as the number of positions containing $1$. Mapping each binary string to the subset of index positions containing $1$ establishes a classic bijection between binary strings of length $n$ and subsets of $\{1, 2, \dots, n\}$.

Binary Strings of Length 3 and Their Corresponding Position Subsets Diagram listing all 8 binary strings of length 3, mapping each string to its corresponding subset of 1-positions, highlighting weight-2 strings. Bijection: Length-3 Binary Strings ⟷ Subsets of {1, 2, 3} Binary String Selected Positions Subset Weight (r) 000 ∅ 0 001 {3} 1 010 {2} 1 011 {2, 3} 2 100 {1} 1 101 {1, 3} 2 110 {1, 2} 2 111 {1, 2, 3} 3 Total Words = 2³ = 8; Exactly C(3, 2) = 3 Words Have Weight r = 2
Figure 4.7: Binary strings of length $n$ with weight $r$ map bijectively to $r$-element subsets of $\{1, 2, \dots, n\}$.

Stars and Bars, with Upper and Lower Bounds

Suppose $N$ indistinguishable objects enter $k$ labeled bins ($N \ge 0, k \ge 1$), allowing empty bins. An allocation corresponds to a weak composition of $N$: an integer vector $(x_1, x_2, \dots, x_k)$ satisfying $\sum_{i=1}^k x_i = N$ with $x_i \ge 0$.

When each bin must receive at least $\ell_i$ objects, set $y_i = x_i - \ell_i$ and $M = N - \sum_i \ell_i$. If $M \ge 0$, the number of allocations is $\binom{M+k-1}{k-1}$; if $M < 0$, there are no valid allocations.

Representing the $N$ objects as stars (*) and separating the $k$ bins using $k-1$ bars (|) yields a sequence of length $N + k - 1$. Choosing the $k-1$ positions for the bars establishes the unconstrained formula:

$$\#\{(x_1, \dots, x_k) : x_i \ge 0, \, \sum x_i = N\} = \binom{N + k - 1}{k - 1}$$
Stars and Bars Encoding and Variable Shift Visualizer Diagram demonstrating stars and bars layout for vector (2,0,3) using 5 stars and 2 bars, plus variable shift y_i = x_i - l_i for lower bounds. Stars & Bars Encoding: N = 5 Stars, k - 1 = 2 Bars (k = 3 Bins) Encodes Vector (2, 0, 3) Lower Bounds Shift (xᵢ ≥ ℓᵢ): Pre-allocate ℓᵢ items per bin: yᵢ = xᵢ - ℓᵢ ⇒ ∑ yᵢ = N - ∑ ℓᵢ = M Transformed Unconstrained Count = C(M + k - 1, k - 1)
Figure 4.8: $N$ stars and $k-1$ bars encode occupancy vectors. Lower bounds are handled by pre-allocating $\ell_i$ items per bin.

Inclusion–exclusion principle: For two overlapping sets $A$ and $B$, $|A \cup B| = |A| + |B| - |A \cap B|$. For several properties, alternate adding the counts of single violations, subtracting pairwise overlaps, and continuing with higher-order intersections. This prevents outcomes satisfying multiple violations from being counted more than once.

Upper Bounds via Inclusion-Exclusion: When coordinates are restricted by upper bounds $0 \le y_i \le c_i$, we define a property $P_i$ as the condition that bin $i$ violates its upper bound ($y_i \ge c_i + 1$). Applying Inclusion-Exclusion subtracts invalid allocations:

In this formula, treat a term as zero whenever $M - \sum_{i \in S}(c_i+1) < 0$, since no allocations remain for that term.

$\text{Valid Count} = \sum_{S \subseteq \{1, \dots, k\}} (-1)^{|S|} \binom{M - \sum_{i \in S} (c_i + 1) + k - 1}{k - 1}$$

Counting Functions: Injections, Surjections, and Bijections

A function $f: D \to B$ from a domain of size $|D| = n$ to a codomain of size $|B| = m$ assigns each input to one output. In balls-and-bins terminology, this represents distributing $n$ distinct balls into $m$ labeled bins.

All Functions

Total Count: $m^n$

Each of the $n$ domain inputs independently selects one of $m$ codomain targets.

Injections (1-to-1)

Total Count: $P(m,n)$

Requires $n \le m$. Successive inputs choose distinct targets: $m(m-1)\cdots(m-n+1)$.

Surjections (Onto)

Via Inclusion-Exclusion

Requires $n \ge m$. Counts functions where every codomain element has $\ge 1$ preimage.

Formula for Surjections: Subtracting functions missing at least $j$ specified codomain elements using Inclusion-Exclusion yields:

$$\#\{\text{Surjections } D \to B\} = \sum_{j=0}^m (-1)^j \binom{m}{j} (m - j)^n$$
Function Classifications Diagram Diagram showing mapping domain elements to codomain elements for general functions, injections, and surjections. Function Types: Injections vs. Surjections vs. Bijections Injection (n ≤ m) Distinct Outputs Surjection (n ≥ m) Every Target Covered Bijection (n = m) Perfect 1-to-1 Match (n!)
Figure 4.9: Domain-to-codomain structure determines whether functions are injections ($P(m,n)$), surjections, or bijections ($n!$).
Term Alternative Name Semantic Meaning Arrow Count per Target Memory Trick
Injective One-to-One No Sharing (No collisions) 0 or 1 One shooter to One target
Surjective Onto No One Left Out (Full coverage) 1 or more Paint onto a wall — covers every spot
Bijective Correspondence Perfect Pair (Equal sizes) Exactly 1 Speed-dating round where everyone pairs up

The Power of Bijective Proofs in Combinatorics

The core principle of a bijective proof is remarkably simple: If two sets can be perfectly paired up with no items left over, they must contain the exact same number of elements.

The Marble Pairing Analogy

Suppose you have a jar of red marbles ($X$) and blue marbles ($Y$). To check if their quantities match without counting them individually, you pair each red marble with a blue marble:

  • If every red marble gets a blue partner (no sharing / injective) and no blue marble is left alone (full coverage / surjective), you have established a bijection.
  • Therefore: $\text{Size of } X = \text{Size of } Y$.
Hard Set $X$ (Difficult to count) $\quad \overset{f}{\Longleftrightarrow} \quad$ Easy Set $Y$ (Simple to count)

Whenever counting a target set $X$ directly is difficult, we construct a bijection to a simpler set $Y$ and count $Y$ instead!

Applications of Bijective Proofs

Application 1

Counting Subsets via Binary Strings

To count all subsets of $\{1, 2, \dots, n\}$, we map each subset bijectively to an $n$-digit binary string where position $i$ contains 1 if element $i$ is included, and 0 if excluded.

Subset of $\{1, 2, 3\}$ ($X$) Inclusion Choices ($1$=Yes, $0$=No) Binary String ($Y$)
$\emptyset$ (empty)No 1, No 2, No 3000
$\{1\}$Yes 1, No 2, No 3100
$\{2\}$No 1, Yes 2, No 3010
$\{3\}$No 1, No 2, Yes 3001
$\{1, 2\}$Yes 1, Yes 2, No 3110
$\{1, 3\}$Yes 1, No 2, Yes 3101
$\{2, 3\}$No 1, Yes 2, Yes 3011
$\{1, 2, 3\}$Yes 1, Yes 2, Yes 3111

Since each position in an $n$-digit string has $2$ choices, there are $2^n$ total binary strings. The bijection guarantees that the total number of subsets is also $2^n$.

Application 2

Stars and Bars: Distributing Identical Items

Distributing $5$ identical candies among $3$ kids (Alice, Bob, Charlie) maps bijectively to arranging $5$ stars ($\star$) and $2$ bars ($\mid$) dividing the kids' sections.

Candy Distribution (Alice, Bob, Charlie) Stars & Bars String Interpretation
Alice: 2, Bob: 2, Charlie: 1$\star \star \mid \star \star \mid \star$2 left, 2 middle, 1 right
Alice: 5, Bob: 0, Charlie: 0$\star \star \star \star \star \mid \mid$5 left, 0 middle, 0 right
Alice: 0, Bob: 3, Charlie: 2$\mid \star \star \star \mid \star \star$0 left, 3 middle, 2 right
Alice: 1, Bob: 0, Charlie: 4$\star \mid \mid \star \star \star \star$1 left, 0 middle, 4 right

Arranging $5$ stars and $2$ bars requires selecting $2$ bar positions out of $7$ total slots:

$$\binom{5 + 3 - 1}{3 - 1} = \binom{7}{2} = \frac{7 \times 6}{2 \times 1} = 21 \text{ valid distributions}$$
Application 3

City Planning Infrastructure Decisions

A city must decide infrastructure for 10 intersections. Each intersection has 3 mutually exclusive options under city rules:

Option A: Both (Traffic Light + Gas Station)
Option B: Basic (Traffic Light Only)
Option C: Clear (Neither)

Every city infrastructure plan maps bijectively to a 10-letter word over the 3-letter alphabet $\{A, B, C\}$. For example, the plan [Both, Basic, Clear, Both, Clear, Clear, Basic, Both, Basic, Clear] encodes as ABCACBABAC.

Counting 10-letter words over an alphabet of size 3 gives:

$$3^{10} = \mathbf{59,049 \text{ total city plans}}$$

Balls into Bins: Distinguishable and Indistinguishable Objects

One of the most fundamental frameworks in combinatorics is the distribution of $n$ objects (balls) into $k$ containers (bins). To solve any distribution problem correctly, you must first ask two crucial questions:

1. Are the Balls Distinguishable?

Do the balls have unique labels or colors (like balls labeled $a, b, c$ or students $1, 2, 3$), or are they completely identical (like unlabeled white ping-pong balls or dollar bills)?

2. Are the Bins Distinguishable?

Are the bins distinctly named (like Bin $A$ and Bin $B$, or Room $1$ and Room $2$), or are they identical unlabeled cardboard boxes sitting on a table where swapping box positions produces no visible difference?

These choices give four combinations of object and bin distinguishability. Work through each case below, then use the summary matrix to compare their models and counts.


Case 1: Distinct Balls into Labeled Bins ($k^n$)

In this scenario, every single ball is unique (e.g., labeled $a, b, c$), and every bin has a distinct label (e.g., Bin $A$ and Bin $B$).

Real-World Analogy Assigning $n$ named students to $k$ distinct dorm rooms, or assigning $n$ different software tasks to $k$ unique server nodes. Every student/task has an individual identity, and room/server choices are distinguished by name.

Why the Formula is $k^n$

Think about assigning the balls one by one:

  • Ball $a$ can be placed into any of the $k$ bins ($k$ choices).
  • Ball $b$ can be placed into any of the $k$ bins ($k$ choices).
  • Ball $c$ can be placed into any of the $k$ bins ($k$ choices).

By the Multiplication Principle of counting, the total number of distinct assignments is:

$$\underbrace{k \times k \times \dots \times k}_{n \text{ factors}} = k^n$$

Mathematically, this corresponds to the number of functions $f: D \to B$ from a domain $D$ of size $n$ (the balls) to a codomain $B$ of size $k$ (the bins).

Worked Example: $n = 3$ Distinct Balls ($a, b, c$), $k = 2$ Labeled Bins ($A, B$)

Using the formula, we expect $2^3 = \mathbf{8}$ unique assignments. Let's explicitly list all $8$ possible functions mapping each ball to its assigned bin:

1. Bin A: {a,b,c}
Bin B: { }
2. Bin A: {a,b}
Bin B: {c}
3. Bin A: {a,c}
Bin B: {b}
4. Bin A: {a}
Bin B: {b,c}
5. Bin A: {b,c}
Bin B: {a}
6. Bin A: {b}
Bin B: {a,c}
7. Bin A: {c}
Bin B: {a,b}
8. Bin A: { }
Bin B: {a,b,c}
Case 1: Distinct Balls into Labeled Bins Illustration showing 3 distinct colored balls a, b, c distributed into Labeled Bin A and Labeled Bin B producing 2^3 = 8 configurations. Case 1: Distinct Balls (a, b, c) into Labeled Bins (A, B) — 2³ = 8 Outcomes 3 Distinct Balls a b c 1. (A: abc, B: -) Bin A Bin B 2. (A: ab, B: c) Bin A Bin B 3. (A: ac, B: b) Bin A Bin B 4. (A: a, B: bc) Bin A Bin B 5. (A: bc, B: a) Bin A Bin B 6. (A: b, B: ac) Bin A Bin B 7. (A: c, B: ab) Bin A Bin B 8. (A: -, B: abc) Bin A Bin B
Figure 4.10: Distinguishing $3$ colored balls into $2$ labeled bins produces $2^3 = 8$ total functions.

Case 2: Identical Balls into Labeled Bins ($\binom{n+k-1}{k-1}$)

Here, the $n$ balls are completely identical (no labels or colors to distinguish them), but the $k$ bins remain distinctly labeled ($A, B, C, \dots$).

Real-World Analogy Distributing $n$ identical $\$1$ bills into $k$ distinct bank accounts, or placing $n$ identical scoops of vanilla ice cream into $k$ labeled dessert bowls. Because the bills/scoops are identical, we only care about how many go into each bin!

Understanding Occupancy Vectors & Stars and Bars

Because the balls cannot be told apart, an outcome is uniquely determined by an occupancy vector $(x_1, x_2, \dots, x_k)$, where $x_i$ is the number of balls placed in Bin $i$. These non-negative integers must satisfy:

$$x_1 + x_2 + \dots + x_k = n \quad \text{where } x_i \ge 0$$

To count the number of solution vectors, we use the famous Stars and Bars method:

  1. Represent the $n$ identical balls as $n$ stars ($\star$).
  2. Use $k - 1$ vertical bars ($\mid$) as dividers to separate the stars into $k$ distinct bin regions.
  3. Any arrangement of $n$ stars and $k - 1$ bars corresponds to a unique distribution vector.

The total length of the sequence is $n + (k - 1)$ positions. Choosing $k - 1$ positions for the bars yields the formula:

$$\binom{n + k - 1}{k - 1} \quad \text{or equivalently} \quad \binom{n + k - 1}{n}$$
Worked Example: $n = 3$ Identical Balls, $k = 2$ Labeled Bins ($A, B$)

Plugging values into the Stars and Bars formula:

$$\binom{3 + 2 - 1}{2 - 1} = \binom{4}{1} = \mathbf{4} \text{ vectors}$$

The $4$ distinct occupancy vectors $(x_A, x_B)$ and their corresponding Stars and Bars diagrams are:

  • $(3, 0)$ $\implies \star\star\star \mid \quad$ (Bin $A = 3$, Bin $B = 0$)
  • $(2, 1)$ $\implies \star\star \mid \star \quad$ (Bin $A = 2$, Bin $B = 1$)
  • $(1, 2)$ $\implies \star \mid \star\star \quad$ (Bin $A = 1$, Bin $B = 2$)
  • $(0, 3)$ $\implies \quad \mid \star\star\star \quad$ (Bin $A = 0$, Bin $B = 3$)
Case 2: Identical Balls into Labeled Bins (Stars and Bars) Visual explanation of the Stars and Bars method converting 3 identical balls and 1 divider bar into 4 distinct occupancy vectors. Case 2: Identical Balls into Labeled Bins (A, B) — Stars & Bars Method Vector (3, 0): ★★★ | ⇒ Bin A has 3 balls, Bin B has 0 balls Vector (2, 1): ★★ | ★ ⇒ Bin A has 2 balls, Bin B has 1 ball Vector (1, 2): ★ | ★★ ⇒ Bin A has 1 ball, Bin B has 2 balls Vector (0, 3): | ★★★ ⇒ Bin A has 0 balls, Bin B has 3 balls
Figure 4.11: Laying out $3$ identical balls and $1$ divider bar gives $\binom{3+1}{1} = 4$ total outcomes.

Case 3: Distinct Balls into Unlabeled Bins (Set Partitions)

In this case, the $n$ balls are individually distinct ($a, b, c$), but the $k$ bins are unlabeled identical containers.

Real-World Analogy Grouping $n$ distinct team members into $k$ unnamed project clusters. Putting Alice and Bob in Cluster $1$ and Charlie in Cluster $2$ is identical to putting Alice and Bob in Cluster $2$ and Charlie in Cluster $1$, because the cluster names do not exist! Only the grouping structure matters.

Understanding Stirling Numbers of the Second Kind

Dividing $n$ distinct elements into non-empty, unlabeled subsets is called a Set Partition. The number of ways to partition a set of $n$ distinct elements into exactly $j$ non-empty unlabeled subsets is given by the Stirling Number of the Second Kind, denoted $S(n, j)$ or $\left\{ \begin{matrix} n \\ j \end{matrix} \right\}$.

If we have up to $k$ available unlabeled bins (meaning some bins can remain empty), we sum $S(n, j)$ over all possible numbers of non-empty bins $j$ from $1$ to $k$:

$$\text{Total Outcomes} = \sum_{j=1}^{k} S(n, j)$$
Worked Example: $n = 3$ Distinct Balls ($a, b, c$), $k = 2$ Unlabeled Bins

We compute the sum for $j = 1$ non-empty bin and $j = 2$ non-empty bins:

  • $j = 1$ non-empty bin ($S(3,1) = 1$): Put all $3$ balls into $1$ group $\implies \{\{a, b, c\}\}$.
  • $j = 2$ non-empty bins ($S(3,2) = 3$): Split into $1$ group of size $2$ and $1$ group of size $1$:
    1. $\{\{a, b\}, \{c\}\}$
    2. $\{\{a, c\}, \{b\}\}$
    3. $\{\{b, c\}, \{a\}\}$
$$\text{Total} = S(3, 1) + S(3, 2) = 1 + 3 = \mathbf{4} \text{ set partitions}$$
Case 3: Distinct Balls into Unlabeled Bins Diagram showing the 4 set partitions when grouping distinct balls a, b, c into at most 2 unlabeled containers. Case 3: Distinct Balls into Unlabeled Bins — S(3,1) + S(3,2) = 4 Partitions 1 Non-Empty Bin: S(3,1)=1 a b c {{a, b, c}} 2 Bins: Partition 1 a b c {{a, b}, {c}} 2 Bins: Partition 2 a c b {{a, c}, {b}} 2 Bins: Partition 3 b c a {{b, c}, {a}}
Figure 4.12: Because the bins are unlabeled, only the subset groupings of distinct balls matter.

Case 4: Identical Balls into Unlabeled Bins (Integer Partitions)

In this final scenario, neither the balls nor the bins can be distinguished. Every ball looks identical, and every bin looks identical.

Real-World Analogy Splitting a stash of $n$ identical coins into at most $k$ unnamed stacks on a table. All that matters is the sizes of the non-zero stacks, listed in descending order (e.g., a stack of $2$ and a stack of $1$).

Understanding Integer Partitions

An integer partition of $n$ is a way of writing $n$ as a sum of positive integers, where the order of summands does not matter:

$$n = x_1 + x_2 + \dots + x_j \quad \text{with } x_1 \ge x_2 \ge \dots \ge x_j \ge 1 \quad \text{and } j \le k$$

The total number of outcomes is $p_{\le k}(n)$, the number of partitions of the integer $n$ into at most $k$ positive summands.

Worked Example: $n = 3$ Identical Balls, $k = 2$ Unlabeled Bins

We want to write $3$ as a sum of at most $2$ positive integers:

  1. Partition $(3)$ $\implies$ All $3$ balls placed in $1$ pile. (Second bin is empty).
  2. Partition $(2, 1)$ $\implies$ One pile of $2$ balls, and one pile of $1$ ball.

Hence, there are only $2$ possible outcomes: $(3)$ and $(2, 1)$.

Case 4: Identical Balls into Unlabeled Bins Visual illustration showing integer partitions of 3 into at most 2 parts producing exactly 2 outcomes. Case 4: Identical Balls into Unlabeled Bins — Partitions of 3 into ≤ 2 Parts Outcome 1: Partition (3) 1 pile of 3 balls Outcome 2: Partition (2, 1) 1 pile of 2, 1 pile of 1
Figure 4.13: With indistinguishable balls and bins, counting reduces to finding integer partitions $p_{\le k}(n)$.

These four models form a subset of the broader Twelvefold Way classification. The matrix summarizes their formulas and the results for $n = 3$ balls and $k = 2$ bins.

Paradigm Balls (Objects) Bins (Containers) Mathematical Model General Formula Example ($3$ Balls, $2$ Bins)
Case 1 Distinct ($a, b, c$) Labeled ($A, B$) Functions $D \to B$ $k^n$ $2^3 = \mathbf{8}$ assignments
Case 2 Identical ($\bullet, \bullet, \bullet$) Labeled ($A, B$) Weak Compositions (Stars & Bars) $\binom{n+k-1}{k-1}$ $\binom{3+2-1}{2-1} = \binom{4}{1} = \mathbf{4}$ vectors
Case 3 Distinct ($a, b, c$) Unlabeled ($\square, \square$) Set Partitions ($\le k$ non-empty blocks) $\sum_{j=1}^k S(n, j)$ $S(3,1) + S(3,2) = 1 + 3 = \mathbf{4}$ partitions
Case 4 Identical ($\bullet, \bullet, \bullet$) Unlabeled ($\square, \square$) Integer Partitions ($\le k$ parts) $p_{\le k}(n)$ Partitions of $3$: $(3)$ and $(2,1) \implies \mathbf{2}$ outcomes
The Four Balls and Bins Counting Paradigms A 2x2 matrix grid displaying the four combinations of distinguishable and indistinguishable balls and bins. The Four Counting Paradigms ($n$ Balls into $k$ Bins) LABELED BINS (Distinguishable Containers) UNLABELED BINS (Identical Containers) CASE 1: DISTINCT BALLS + LABELED BINS Model: Functions ($D \to B$) Formula: kⁿ Example (3 balls, 2 bins): 2³ = 8 assignments Order matters for balls; bin names distinguish positions. CASE 3: DISTINCT BALLS + UNLABELED BINS Model: Set Partitions Formula: Σ S(n, j) for j=1..k Example (3 balls, 2 bins): S(3,1) + S(3,2) = 1 + 3 = 4 Groupings of distinct balls into non-empty sets. CASE 2: IDENTICAL BALLS + LABELED BINS Model: Weak Compositions (Occupancy Vectors) Formula: C(n + k - 1, k - 1) Example (3 balls, 2 bins): C(3+1, 1) = 4 vectors Stars and Bars method: only bin counts matter. CASE 4: IDENTICAL BALLS + UNLABELED BINS Model: Integer Partitions Formula: p_k(n) [Partitions of n into ≤ k parts] Example (3 balls, 2 bins): (3) and (2,1) ⇒ 2 outcomes Splitting identical items into unlabelled non-zero piles.
Figure 4.14: Master Overview Matrix comparing the four balls-and-bins paradigms based on object and container distinguishability.

How to Choose the Right Paradigm in Exam Problems

When solving counting problems, use this 2-step decision flowchart:

Decision Flowchart Strategy

  1. Are objects distinct?
    • YES: Look at container distinguishability.
      • If bins are labeled $\implies \mathbf{k^n}$ (Functions)
      • If bins are unlabeled $\implies \mathbf{\sum S(n,j)}$ (Set Partitions)
    • NO (Identical balls): Look at container distinguishability.
      • If bins are labeled $\implies \mathbf{\binom{n+k-1}{k-1}}$ (Stars & Bars)
      • If bins are unlabeled $\implies \mathbf{p_{\le k}(n)}$ (Integer Partitions)
Quick Check: Notice how outcomes drop dramatically as distinguishability is removed! For $n=3, k=2$: $$\text{Case 1 } (8 \text{ outcomes}) \ge \text{Case 2 } (4 \text{ outcomes}) = \text{Case 3 } (4 \text{ outcomes}) > \text{Case 4 } (2 \text{ outcomes})$$

How Many Allocations Satisfy All Capacity Constraints?

Now that we understand how basic choices combine sequentially and additively, let's explore what happens when distribution problems involve capacity limits and bounds.

Suppose five identical supply packs must be distributed among three named stations: $A$, $B$, and $C$. Station $A$ requires at least one pack and can hold at most three; station $B$ can hold at most two; station $C$ requires at least one and can hold at most four. How many valid allocations are possible?

An allocation is completely described by its occupancy vector $(x_A, x_B, x_C)$, representing the number of packs assigned to each station. We seek the number of integer solutions to the system:

$$x_A + x_B + x_C = 5, \qquad 1 \le x_A \le 3, \quad 0 \le x_B \le 2, \quad 1 \le x_C \le 4$$

The stations are distinct, so $(1, 2, 2)$ and $(2, 1, 2)$ represent different physical allocations. However, because the supply packs are identical, exchanging two packs at the same or different stations does not yield a new outcome. If the packs instead possessed unique serial numbers, the vector $(1, 2, 2)$ would describe $30$ distinct labeled assignments!

1. Case Analysis

Fix one variable and enumerate allowed sub-cases (best for small total $N$).

2. Variable Shift

Pre-allocate minimum required items to handle lower bounds ($\ge 1$).

3. Inclusion-Exclusion

Subtract illegal overflow outcomes that exceed station upper limits.

4. Multinomial Weight

Multiply vectors by arrangement factors if items are distinct/labeled.


Method 1: Exhaustive Case Enumeration (Case Analysis)

When the number of objects is small, partitioning the problem into mutually exclusive cases based on one variable is the most direct approach.

Motivating Problem

Exhaustive Enumeration of Capacity Vectors

By fixing $x_A$ within its valid range $x_A \in \{1, 2, 3\}$, we evaluate all permitted pairs $(x_B, x_C)$ where $x_C = 5 - x_A - x_B$ (applying the Addition Principle across the mutually exclusive cases for $x_A$):

Packs at Station $A$ ($x_A$) Allowed Pairs $(x_B, x_C)$ Valid Occupancy Vectors Count
$x_A = 1$ $(0,4), (1,3), (2,2)$ $(1,0,4), (1,1,3), (1,2,2)$ 3
$x_A = 2$ $(0,3), (1,2), (2,1)$ $(2,0,3), (2,1,2), (2,2,1)$ 3
$x_A = 3$ $(0,2), (1,1)$ $(3,0,2), (3,1,1)$ 2

By the Addition Principle ($3 + 3 + 2$), there are exactly $8$ valid occupancy vectors for identical packs.

Station Capacity Allocation Tree Diagram Tree diagram showing the distribution of 5 identical packs across 3 stations A, B, and C with upper and lower bounds, yielding 8 total valid occupancy vectors. Station Capacity Allocation Tree ($N = 5$ Packs into 3 Bins) 5 Packs N = 5 x_A = 1 x_A = 2 x_A = 3 Pairs (x_B, x_C): (0,4), (1,3), (2,2) 3 Vectors Pairs (x_B, x_C): (0,3), (1,2), (2,1) 3 Vectors Pairs (x_B, x_C): (0,2), (1,1) 2 Vectors
Figure 4.15: Partitioning allocations by $x_A$ yields $3 + 3 + 2 = 8$ valid occupancy vectors satisfying all station constraints.

Method 2: Variable Shift (Pre-allocation for Lower Bounds)

Instead of manually listing cases, how can we solve this algebraically? Lower bounds like $x_A \ge 1$ and $x_C \ge 1$ require minimum allocations before any remaining supply is distributed. We handle this using a variable shift (pre-allocation):

  1. Pre-allocate minimum required items: Give $1$ pack to station $A$ and $1$ pack to station $C$ immediately.
  2. Define shifted non-negative variables: $$x_A' = x_A - 1 \ge 0, \qquad x_B' = x_B \ge 0, \qquad x_C' = x_C - 1 \ge 0$$
  3. Reduce the total supply pool: Subtract the $2$ pre-allocated packs from $5$: $$x_A' + x_B' + x_C' = 5 - 1 - 1 = 3$$
  4. Transform upper bounds: $$0 \le x_A' \le 2, \qquad 0 \le x_B' \le 2, \qquad 0 \le x_C' \le 3$$
Variable Shift and Pre-Allocation Visualizer Diagram showing 5 total supply packs, reserving 1 pack for Station A and 1 pack for Station C, leaving 3 remaining packs to distribute with non-negative shifted variables. Pre-Allocation Strategy: Simplifying Lower Bounds ($x_i \ge \ell_i$) 1. Total Initial Pool (5 Packs) P1 P2 P3 P4 P5 x_A + x_B + x_C = 5 2. Reserve Minimums (-2) Station A gets 1 (x_A ≥ 1) Station C gets 1 (x_C ≥ 1) Locked: 2 Packs 3. Shifted Allocation Pool P1 P2 P3 x'_A + x'_B + x'_C = 3 Unconstrained Base Model
Figure 4.16: Pre-allocating $1$ pack to station $A$ and $1$ pack to station $C$ reduces the problem to assigning $3$ free packs among $3$ bins with shifted variables ($x_i' \ge 0$).

Method 3: Upper Bounds via Inclusion-Exclusion (PIE)

Now that we have the simplified problem $x_A' + x_B' + x_C' = 3$ with non-negative integers ($x_i' \ge 0$), we can use Stars and Bars to count the total unconstrained solutions, then subtract invalid allocations that violate the upper capacity limits.

Inclusion-Exclusion Capacity Filter Visualizer Flow diagram showing 10 unconstrained Stars and Bars solutions passing through an upper bound filter that removes 2 overflow violations, yielding 8 valid vectors. Inclusion-Exclusion Principle: Filtering Capacity Overflows Unconstrained Stars & Bars C(3 + 3 - 1, 3 - 1) 10 Total Raw Vectors Capacity Violations (Minus) x'_A ≥ 3 ⇒ Vector (3,0,0) [1] x'_B ≥ 3 ⇒ Vector (0,3,0) [1] Valid Vectors 10 - 2 = 8
Figure 4.17: Subtracting the $2$ illegal overflow vectors from the $10$ unconstrained Stars and Bars solutions leaves exactly $8$ valid occupancy vectors.

Method 4: Labeled Items & Multinomial Coefficient Weighting

What if the 5 supply packs are distinct / labeled (e.g., Pack #1, Pack #2, ..., Pack #5) rather than identical? While there remain only 8 valid occupancy vectors for bin counts, each vector expands into multiple distinct physical pack assignments.

The number of ways to assign $5$ distinct labeled items into bins of sizes $x_A, x_B, x_C$ is given by the multinomial coefficient:

$$\text{Distinct Assignments} = \binom{5}{x_A, x_B, x_C} = \frac{5!}{x_A! \, x_B! \, x_C!}$$
Occupancy Vector $(x_A, x_B, x_C)$ Multinomial Expansion Formula Calculation Distinct Labeled Assignments
$(1, 0, 4)$$\frac{5!}{1! \, 0! \, 4!}$$\frac{120}{1 \times 1 \times 24}$5
$(1, 1, 3)$$\frac{5!}{1! \, 1! \, 3!}$$\frac{120}{1 \times 1 \times 6}$20
$(1, 2, 2)$$\frac{5!}{1! \, 2! \, 2!}$$\frac{120}{1 \times 2 \times 2}$30
$(2, 0, 3)$$\frac{5!}{2! \, 0! \, 3!}$$\frac{120}{2 \times 1 \times 6}$10
$(2, 1, 2)$$\frac{5!}{2! \, 1! \, 2!}$$\frac{120}{2 \times 1 \times 2}$30
$(2, 2, 1)$$\frac{5!}{2! \, 2! \, 1!}$$\frac{120}{2 \times 2 \times 1}$30
$(3, 0, 2)$$\frac{5!}{3! \, 0! \, 2!}$$\frac{120}{6 \times 1 \times 2}$10
$(3, 1, 1)$$\frac{5!}{3! \, 1! \, 1!}$$\frac{120}{6 \times 1 \times 1}$20
Total Labeled Physical Assignments (Sum): 155
Identical Vector vs Labeled Expansion Diagram Comparison diagram showing how 1 identical occupancy vector (1,2,2) expands into 30 distinct labeled assignments using multinomial coefficients. Identical Items (1 Vector) vs. Labeled Items (30 Assignments) IDENTICAL PACKS (Occupancy Vector) Vector (1, 2, 2) Station A: 1 pack | Station B: 2 | Station C: 2 Counts as EXACTLY 1 Outcome LABELED PACKS (Distinct Serial Numbers) Multinomial Formula: 5! / (1! 2! 2!) = 30 Assignments 30 Unique Physical Configurations
Figure 4.18: A single occupancy vector like $(1,2,2)$ represents $1$ outcome for identical items, but expands into $30$ distinct physical assignments when items are labeled.
Summary Checklist for Constrained Allocations
  • Identical Packs + Capacity Bounds: Yields $8$ valid occupancy vectors.
  • Labeled Packs + Capacity Bounds: Summing multinomial weights across all $8$ vectors yields $155$ distinct physical assignments.
  • Unconstrained Labeled Placements: Placing $5$ distinct packs into $3$ stations without bounds yields $3^5 = 243$ total possible functions. Thus, satisfying all station capacity limits has a probability of $\frac{155}{243} \approx \mathbf{63.78\%}$.

Finite Probability Applications

A sample space $\Omega$ is the set of all possible outcomes of an experiment. An event $E \subseteq \Omega$ is a subset of outcomes. When $\Omega$ is finite and all outcomes are equally likely, the probability of event $E$ is:

$$\Pr(E) = \frac{|E|}{|\Omega|}$$
Worked Example: Sampling Tokens Without Replacement

A bag contains 2 Red tokens and 3 Blue tokens ($N=5$ total). Draw 2 tokens uniformly without replacement. What is the probability of drawing exactly 1 Red and 1 Blue token?

  • Sample Space Size: Total unordered pairs of tokens is $|\Omega| = \binom{5}{2} = 10$.
  • Favorable Event Size: Choose 1 Red token from 2, and 1 Blue token from 3: $|E| = \binom{2}{1} \binom{3}{1} = 2 \times 3 = 6$.
  • Probability: $$\Pr(\text{1 Red, 1 Blue}) = \frac{\binom{2}{1}\binom{3}{1}}{\binom{5}{2}} = \frac{6}{10} = \frac{3}{5}$$

General Hypergeometric Distribution: Sampling $r$ objects without replacement from a population of $N$ objects containing $K$ marked items yields exactly $j$ marked items with probability:

$$\Pr(X = j) = \frac{\binom{K}{j} \binom{N-K}{r-j}}{\binom{N}{r}}$$

Occupancy Problems: Multinomial Distributions

When $n$ distinct balls choose $k$ labeled bins independently with probabilities $p_1, p_2, \dots, p_k$ (where $\sum p_i = 1$), the resulting random occupancy vector $(X_1, X_2, \dots, X_k)$ follows the multinomial distribution:

$$\Pr(X_1 = n_1, \dots, X_k = n_k) = \frac{n!}{n_1! \, n_2! \cdots n_k!} \prod_{i=1}^k p_i^{n_i}$$

For uniform choices ($p_i = 1/k$), every specific assignment of distinct balls has probability $1/k^n$. However, different occupancy vectors possess different numbers of distinct ball assignments ($\frac{n!}{n_1! \cdots n_k!}$), meaning occupancy vectors are not equally likely!

Resolving the Opening Allocation for Labeled Packs

For the 5 labeled supply packs assigned to 3 stations uniformly ($p_A = p_B = p_C = 1/3$), we sum multinomial weights $\frac{5!}{x_A! \, x_B! \, x_C!}$ across the 8 valid vectors:

Vector $(x_A, x_B, x_C)$ Multinomial Weight $\frac{5!}{x_A! x_B! x_C!}$ Vector $(x_A, x_B, x_C)$ Multinomial Weight $\frac{5!}{x_A! x_B! x_C!}$
$(1,0,4)$$5$$(2,1,2)$$30$
$(1,1,3)$$20$$(2,2,1)$$30$
$(1,2,2)$$30$$(3,0,2)$$10$
$(2,0,3)$$10$$(3,1,1)$$20$

Total Labeled Assignments = $5 + 20 + 30 + 10 + 30 + 30 + 10 + 20 = \mathbf{155}$.
Probability of Satisfying Capacities = $\frac{155}{3^5} = \mathbf{\frac{155}{243}} \approx 63.78\%$.


Counting Binary Strings and Constrained Words

Binary strings—sequences formed exclusively from bits 0 and 1—are the foundational language of computer science, data compression, digital logic design, and error-correcting codes. Understanding how to count these strings under various structural rules is a core skill in combinatorics.

Unconstrained Binary Strings

Without any restriction, a binary string of length $n$ has $2$ choices (0 or 1) for each position. By the Multiplication Principle, there are exactly $2^n$ total binary strings of length $n$.

Constrained Binary Strings

In practice, hardware or algorithms often impose rules, such as forbidding consecutive ones (11) to prevent signal interference in circuits or back-to-back resource access in CPU scheduling.

Real-World Analogy: Buffer Cooling & Task Scheduling Imagine scheduling $n$ time slots on a server. A 1 represents running an intensive high-power task, while a 0 represents an idle/cooling slot. If running high-power tasks in consecutive slots causes overheating, we forbid adjacent 1s (the pattern 11). Every active slot 1 must be followed by at least one cooling slot 0!

Fixed Weight Selection: The Compressed-Position Bijection

Suppose we fix the number of 1s in our string. The number of 1s in a binary string is called its weight ($r$). How many valid binary strings of length $n$ contain exactly $r$ ones such that no two ones are adjacent?

Compressed-Position Bijection (Fixed Weight $r$, No Adjacent Ones)

Let $1 \le i_1 < i_2 < \dots < i_r \le n$ be the indices where 1s are placed in a length-$n$ word with no adjacent ones ($i_{j+1} \ge i_j + 2$).

Define compressed position indices $z_j = i_j - (j - 1)$ for $j = 1, 2, \dots, r$. Then:

$$1 \le z_1 < z_2 < \dots < z_r \le n - r + 1$$

This bijection removes $1$ mandatory separation space between consecutive 1s, mapping constrained words of length $n$ with weight $r$ directly to unrestricted $r$-element subsets of $\{1, 2, \dots, n-r+1\}$. Thus, the count is exactly:

$$\text{Valid Words of Length } n \text{ with } r \text{ Ones} = \binom{n - r + 1}{r}$$

Why Does Compression Work? Step-by-Step Mechanics

In an unrestricted selection of $r$ positions out of $n$, any subset works ($\binom{n}{r}$). But when 1s cannot touch, each 1 after the first absorbs at least one mandatory zero spacer to its left.

  1. The 1st one ($i_1$) requires 0 forced spacers before it: $z_1 = i_1 - 0$.
  2. The 2nd one ($i_2$) requires at least 1 forced zero spacer between $i_1$ and $i_2$: $z_2 = i_2 - 1$.
  3. The 3rd one ($i_3$) requires at least 2 cumulative forced zero spacers: $z_3 = i_3 - 2$.
  4. The $r$-th one ($i_r$) requires at least $r-1$ cumulative forced zero spacers: $z_r = i_r - (r - 1)$.

By subtracting these mandatory spacer counts, we "collapse" or "compress" the array down by $r - 1$ slots. The original array of size $n$ shrinks down to an effective domain size of $n - (r - 1) = n - r + 1$.

Compressed Position Bijection Diagram Diagram showing length 5 string 10010 with 1-positions at 1 and 4 compressing down to subset {1, 3} in a reduced size 4 domain. Compression Bijection: String "10010" (n = 5, r = 2) Original Array Positions (n = 5): i₁ = 1 1 0 Spacer 0 i₂ = 4 1 0 z₁ = i₁ - 0 = 1 z₂ = i₂ - 1 = 3 Compressed Domain (n - r + 1 = 4): 1 z₁ = 1 2 3 z₂ = 3 4 For n = 5, r = 2: C(5 - 2 + 1, 2) = C(4, 2) = 6 Valid Constrained Words
Figure 4.19: The compression bijection $z_j = i_j - (j-1)$ removes spacer zeros, mapping non-adjacent 1-positions in size $n$ to unrestricted subsets of size $n - r + 1$.
Worked Example

Complete Enumeration for Length $n = 5$, Weight $r = 2$

Without restrictions, choosing $2$ positions out of $5$ yields $\binom{5}{2} = 10$ binary words. Enforcing that no two 1s are adjacent eliminates $4$ words containing 11, leaving exactly $6$ valid words:

Constrained Binary Word Original 1-Positions $(i_1, i_2)$ Bijection Formula $z_j = i_j - (j-1)$ Compressed Subset $\{z_1, z_2\} \subseteq \{1, 2, 3, 4\}$
10100 $(1, 3)$ $z_1 = 1 - 0 = 1, \quad z_2 = 3 - 1 = 2$ {1, 2}
10010 $(1, 4)$ $z_1 = 1 - 0 = 1, \quad z_2 = 4 - 1 = 3$ {1, 3}
10001 $(1, 5)$ $z_1 = 1 - 0 = 1, \quad z_2 = 5 - 1 = 4$ {1, 4}
01010 $(2, 4)$ $z_1 = 2 - 0 = 2, \quad z_2 = 4 - 1 = 3$ {2, 3}
01001 $(2, 5)$ $z_1 = 2 - 0 = 2, \quad z_2 = 5 - 1 = 4$ {2, 4}
00101 $(3, 5)$ $z_1 = 3 - 0 = 3, \quad z_2 = 5 - 1 = 4$ {3, 4}

Notice how every 2-element subset of $\{1, 2, 3, 4\}$ matches 1-to-1 with a valid string of length $5$ with non-adjacent 1s!

Valid vs Invalid Binary Strings Classification Diagram showing the 10 total binary strings of length 5 and weight 2 divided into 6 valid words with no 11s and 4 invalid words with adjacent 11s. Classification of Length-5 Binary Strings with Weight r = 2 Valid Words (No "11"): C(4, 2) = 6 10100 10010 10001 01010 01001 00101 ✓ Every 1 is separated by at least one 0 Rejected Words (Contains "11"): 4 11000 01100 00110 00011 ✗ Rejected due to adjacent "11" substring
Figure 4.20: Total unconstrained weight-2 words $\binom{5}{2} = 10$ split into 6 valid words and 4 rejected words with adjacent 11s.

Counting All Weights: The Fibonacci Recurrence

What if we do not fix the weight $r$, but instead want to count all binary strings of length $n$ that contain no adjacent 1s? Let $a_n$ denote this total count.

We can construct any valid length-$n$ string by considering its ending symbol:

Case 1: String ends in 0

If the final bit is 0, the preceding prefix can be any valid binary word of length $n-1$.

Because adding a 0 never violates the "no adjacent 1s" constraint, there are exactly $a_{n-1}$ such words.

Case 2: String ends in 1

If the final bit is 1, the penultimate bit must be 0 (to avoid ending in 11).

Thus the suffix is fixed as 01, and the remaining prefix is any valid binary word of length $n-2$, giving $a_{n-2}$ such words.

Because these two cases are mutually exclusive and cover all possibilities, we obtain the famous Fibonacci recurrence:

$$a_n = a_{n-1} + a_{n-2}, \qquad \text{Base cases: } a_0 = 1, \quad a_1 = 2$$
Fibonacci Recurrence Decomposition Diagram Diagram showing how valid length n words decompose into words ending in 0 (length n-1) and words ending in 01 (length n-2). Recursive Partitioning of Length-n Words (a_n = a_{n-1} + a_{n-2}) Valid Words of Length n Total Count = a_n Ends in "0" Prefix: Any valid word of length n-1 Count = a_{n-1} Ends in "01" Prefix: Any valid word of length n-2 Count = a_{n-2}
Figure 4.21: Partitioning valid words by their suffix yields the Fibonacci recurrence $a_n = a_{n-1} + a_{n-2}$.
Equivalence Between Sum of Binomial Coefficients and Fibonacci Sequence

Alternatively, we can find $a_n$ by summing the fixed-weight counts $\binom{n - r + 1}{r}$ over all possible numbers of ones $r$:

$$a_n = \sum_{r=0}^{\lfloor(n+1)/2\rfloor} \binom{n - r + 1}{r}$$

For length $n = 5$, computing terms for $r = 0, 1, 2, 3$ yields:

Weight $r$ Formula $\binom{5 - r + 1}{r}$ Term Value Physical Meaning
$r = 0$$\binom{6}{0}$1All-zero string (00000)
$r = 1$$\binom{5}{1}$5Single 1 placed anywhere
$r = 2$$\binom{4}{2}$6Two non-adjacent 1s (from compression)
$r = 3$$\binom{3}{3}$1Three non-adjacent 1s (10101)

Total $a_5 = 1 + 5 + 6 + 1 = \mathbf{13}$ words.
Checking the Fibonacci Sequence: $a_0=1, \, a_1=2, \, a_2=3, \, a_3=5, \, a_4=8, \, a_5=\mathbf{13}$ ✓


Combinatorial Model Selection Chart Decision flowchart showing how string counting problems map to distinct combinatorial paradigms. Model Selection: Binary Words vs. Balls & Bins vs. Permutations UNCONSTRAINED WORDS Model: Independent choices Formula: 2ⁿ Example (n=5): 2⁵ = 32 binary words No restrictions on adjacent symbols. CONSTRAINED (FIXED WEIGHT) Model: Compressed Subsets Formula: C(n - r + 1, r) Example (n=5, r=2): C(4, 2) = 6 words Removes spacer zero positions. CONSTRAINED (ALL WEIGHTS) Model: Fibonacci Recurrence Formula: aₙ = aₙ₋₁ + aₙ₋₂ Example (n=5): a₅ = 13 total words Decomposes by ending suffix 0 vs 01.
Figure 4.22: Selecting the correct counting model based on whether constraints specify fixed weights or all valid lengths.

Choose the Right Model for Balls, Bins, and Words

Hands-On Investigation

Investigation: Model Selection & Computational Validation

Task 1
Warm-Up Models

Distinct anagram arrangements of $\{A,A,B,B,C\}$: $\frac{5!}{2!2!1!} = 30$. Binary words of length 5, weight 2: $\binom{5}{2} = 10$. Allocations of 5 identical objects to 3 bins: $\binom{5 + 3 - 1}{3 - 1} = \binom{7}{2} = 21$.

Task 2
Capacity Proof

The 8 capacity occupancy vectors sum to 155 labeled assignments. Uniform selection probability $= 155 / 3^5 = 155 / 243 \approx 63.79\%$.

Task 3
Constrained Words

Bijection $z_j = i_j - (j-1)$ proves length 5 with weight 2 has $\binom{4}{2} = 6$ words; total across all weights gives Fibonacci term $a_5 = 13$.


Deliverables & Assessment Rubric (25 Points)

Criteria Point Value Requirements & Expectations
Model Distinction 5 Points Clear conceptual distinction between occupancy vectors, distinct ball functions, and strings.
Capacity Proof 5 Points Rigorous derivation of the 8 capacity vectors using variable shifts and Inclusion-Exclusion.
Probability Argument 5 Points Correct application of multinomial weights to establish $155$ labeled assignments and $155/243$ probability.
Constrained Bijection 5 Points Formal proof of the compressed-position bijection for non-adjacent ones, including boundary cases.
Computational Checks 5 Points Reproducible enumeration algorithms matching all theoretical values ($8$ vectors, $155$ assignments, $13$ binary words).

Next in the Series

In Chapter 5: Algorithmic Generation of Combinatorial Structures, we'll explore generating each object once, then ranking, unranking, and sampling it efficiently.