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:
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).
Common Applications of the Multiplication Principle
Wardrobe Combinations
Choosing from 5 shirts and 3 pants yields $5 \times 3 = 15$ complete outfits.
Passwords & PIN Codes
A 4-digit PIN with digits 0–9 yields $10 \times 10 \times 10 \times 10 = 10^4 = 10,000$ codes.
Sequential Factorials ($n!$)
Arranging $n$ distinct items in a row uses descending choices: $n \times (n-1) \times \cdots \times 1 = n!$.
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,
Using $n! = n(n-1)\cdots 1$ and the convention $0! = 1$, split the factors of $n!$ after the first $r$ factors:
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
In short: permutations count the chosen objects and their order; combinations count only which objects were chosen.
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:
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:
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:
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.
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?
Scenario B: Arrange All 10 Books by Subject
All books of the same subject must be kept together in adjacent blocks.
Detailed Breakdown for Scenario B (Block Strategy):
- 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.).
- 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.
- 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}$$
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$.
The Multinomial Coefficient
If a multiset contains $n$ total objects of $k$ distinct types with multiplicities $n_1, n_2, \dots, n_k$ (where $\sum n_i = n$), the number of distinct linear permutations is given by the multinomial coefficient:
Proof: Temporarily label every object uniquely, producing $n!$ permutations. Erasing labels maps exactly $n_1! n_2! \cdots n_k!$ labeled arrangements to each visible word, because labels within each symbol type can be permuted independently without altering the string.
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}$$
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\}$.
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:
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.
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:
An Intuitive Mental Model: The Party Target Game
Imagine two groups at a party: Group A (Shooters) aiming arrows at Group B (Targets). Every shooter in $A$ must launch exactly one arrow to a target in $B$. How those arrows land defines the core properties of functions:
1. Injective ("One-to-One")
Core Rule: No sharing. Two shooters never hit the same target.
- Target rule: Each target gets hit 0 or 1 time.
- Targets can be left out untouched.
- Requires $|A| \le |B|$.
- Example: Unique SSNs assigned to citizens.
2. Surjective ("Onto")
Core Rule: Total coverage. Not a single target is left out.
- Target rule: Each target gets hit 1 or more times.
- Shooters can share a target.
- Requires $|A| \ge |B|$.
- Example: Assigning students so every classroom has $\ge 1$ student.
3. Bijective ("Correspondence")
Core Rule: Perfect match. Both Injective and Surjective.
- Target rule: Each target gets hit exactly 1 time.
- No targets left out, no sharing.
- Guarantees $|A| = |B|$.
- Example: Pairing up dance partners perfectly.
| 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$.
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
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 3 | 000 |
| $\{1\}$ | Yes 1, No 2, No 3 | 100 |
| $\{2\}$ | No 1, Yes 2, No 3 | 010 |
| $\{3\}$ | No 1, No 2, Yes 3 | 001 |
| $\{1, 2\}$ | Yes 1, Yes 2, No 3 | 110 |
| $\{1, 3\}$ | Yes 1, No 2, Yes 3 | 101 |
| $\{2, 3\}$ | No 1, Yes 2, Yes 3 | 011 |
| $\{1, 2, 3\}$ | Yes 1, Yes 2, Yes 3 | 111 |
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$.
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:
City Planning Infrastructure Decisions
A city must decide infrastructure for 10 intersections. Each intersection has 3 mutually exclusive options under city rules:
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:
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$).
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:
Bin B: { }
Bin B: {c}
Bin B: {b}
Bin B: {b,c}
Bin B: {a}
Bin B: {a,c}
Bin B: {a,b}
Bin B: {a,b,c}
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$).
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:
- Represent the $n$ identical balls as $n$ stars ($\star$).
- Use $k - 1$ vertical bars ($\mid$) as dividers to separate the stars into $k$ distinct bin regions.
- 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 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.
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$:
- $\{\{a, b\}, \{c\}\}$
- $\{\{a, c\}, \{b\}\}$
- $\{\{b, c\}, \{a\}\}$
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.
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:
- Partition $(3)$ $\implies$ All $3$ balls placed in $1$ pile. (Second bin is empty).
- 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)$.
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 |
How to Choose the Right Paradigm in Exam Problems
When solving counting problems, use this 2-step decision flowchart:
Decision Flowchart Strategy
- 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)
- YES: Look at container distinguishability.
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:
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.
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.
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):
- Pre-allocate minimum required items: Give $1$ pack to station $A$ and $1$ pack to station $C$ immediately.
- 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$$
- Reduce the total supply pool: Subtract the $2$ pre-allocated packs from $5$: $$x_A' + x_B' + x_C' = 5 - 1 - 1 = 3$$
- Transform upper bounds: $$0 \le x_A' \le 2, \qquad 0 \le x_B' \le 2, \qquad 0 \le x_C' \le 3$$
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.
Step-by-Step Inclusion-Exclusion Calculation
- Unconstrained Solutions (Stars and Bars): Place $3$ identical items into $3$ bins: $$\binom{3 + 3 - 1}{3 - 1} = \binom{5}{2} = 10 \text{ total allocations}$$
- Identify Upper-Bound Violations:
- Station $A$ capacity is $x_A \le 3 \implies x_A' \le 2$. A violation occurs if $x_A' \ge 3$. Only $1$ vector violates this: $(3, 0, 0)$.
- Station $B$ capacity is $x_B \le 2 \implies x_B' \le 2$. A violation occurs if $x_B' \ge 3$. Only $1$ vector violates this: $(0, 3, 0)$.
- Station $C$ capacity is $x_C \le 4 \implies x_C' \le 3$. A violation occurs if $x_C' \ge 4$, which is impossible since we only have $3$ total packs!
- Subtract Overflows from Unconstrained Total: $$\text{Valid Vectors} = 10 - (\text{Violations at } A) - (\text{Violations at } B) = 10 - 1 - 1 = \mathbf{8}$$
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:
| 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 | ||
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:
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:
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:
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.
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:
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:
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.
- The 1st one ($i_1$) requires 0 forced spacers before it: $z_1 = i_1 - 0$.
- The 2nd one ($i_2$) requires at least 1 forced zero spacer between $i_1$ and $i_2$: $z_2 = i_2 - 1$.
- The 3rd one ($i_3$) requires at least 2 cumulative forced zero spacers: $z_3 = i_3 - 2$.
- 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$.
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!
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:
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$:
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}$ | 1 | All-zero string (00000) |
| $r = 1$ | $\binom{5}{1}$ | 5 | Single 1 placed anywhere |
| $r = 2$ | $\binom{4}{2}$ | 6 | Two non-adjacent 1s (from compression) |
| $r = 3$ | $\binom{3}{3}$ | 1 | Three 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}$ ✓
Choose the Right Model for Balls, Bins, and Words
Investigation: Model Selection & Computational Validation
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$.
Capacity Proof
The 8 capacity occupancy vectors sum to 155 labeled assignments. Uniform selection probability $= 155 / 3^5 = 155 / 243 \approx 63.79\%$.
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.