Combinatorics
4.1 Counting Principles
Section titled “4.1 Counting Principles”Rule of Sum. If task can be done in ways and task in ways, and they cannot both be Done, then or can be done in ways.
Rule of Product. If task can be done in ways and task in ways independently, then and together can be done in ways.
4.2 Permutations and Combinations
Section titled “4.2 Permutations and Combinations”Permutations: — ordered arrangements of items from .
Combinations: — unordered selections of items from .
Theorem 4.1 (Binomial Theorem).
Theorem 4.2 (Pascal”s Identity).
Proof. Every -subset of either contains (giving ways To choose the remaining ) or does not contain (giving ways to choose all From ).
4.3 Inclusion-Exclusion Principle
Section titled “4.3 Inclusion-Exclusion Principle”Theorem 4.3 (Inclusion-Exclusion). For finite sets :
Proof (for two sets). Every element of is in or or both. Counting counts elements in twice, so we subtract once: .
For the general case, an element in exactly of the sets is counted time, which is correct.
Worked Example. How many integers from 1 to 1000 are not divisible by 2, 3, or 5?
Let = multiples of 2, = multiples of 3, = multiples of 5.
, , .
, , .
.
.
Not divisible by 2, 3, or 5: .
Worked Example. How many integers from 1 to 500 are divisible by 3 or 7 but not by 5?
Solution
Let = multiples of 3, = multiples of 7, = multiples of 5 in .
.
.
Divisible by 3 or 7: .
Divisible by 3 or 7 and by 5: .
Divisible by 3 or 7 but not by 5: .
4.4 Stars and Bars
Section titled “4.4 Stars and Bars”Theorem 4.4. The number of ways to distribute identical objects into distinct bins is .
Proof. The problem is equivalent to placing dividers among objects, giving arrangements.
Worked Example. How many solutions does have with ?
Solution
Substitute . Then with . By stars and bars: .
Worked Example. How many solutions does have with ?
Solution
Directly by stars and bars: .
4.5 The Pigeonhole Principle
Section titled “4.5 The Pigeonhole Principle”Theorem 4.5 (Pigeonhole Principle). If objects are placed into boxes and Then at Least one box contains at least objects.
Proof. If every box contained at most objects, the total would be at most Contradicting that there are objects.
Worked Example. In a class of 400 students, at least how many were born in the same month?
Solution
There are 12 months (boxes) and 400 students (objects). By the pigeonhole principle, some month Has at least students.
Worked Example. Show that among any integers from Two of them Differ by exactly .
Solution
Partition into pigeonholes: , , . Each pair sums to … Let me rephrase.
Partition into , , , . These are disjoint sets. If we select integers from By the pigeonhole principle two must lie in the Same set And their difference is .
Worked Example. Prove that any sequence of distinct real numbers contains a monotone (increasing or decreasing) subsequence of length .
Solution
Let be the sequence. For each Let be the length of the Longest increasing subsequence starting at And the length of the longest decreasing Subsequence starting at .
Suppose for contradiction that every monotone subsequence has length at most . Then and So there are at most distinct ordered pairs . Since we have elements, by the pigeonhole principle two indices Have .
If Then (append before the increasing subsequence starting At ), contradicting .
If Then Contradicting .
Either way we have a contradiction.
Theorem 4.6 (Generalised Pigeonhole Principle). If objects are placed into boxes, then at Least one box contains at least objects. Equivalently, if each box contains at most objects, then the total number of objects is at most .
Worked Example. A drawer contains red, blue, and yellow socks. How many socks must be drawn (without looking) to guarantee at least 4 socks of the same colour?
Solution
There are 3 colours (boxes). By the generalised pigeonhole principle, drawing socks guarantees At least of one colour. We need So Giving .
With 9 socks it is possible to have 3 of each colour (no colour reaches 4). With 10 socks, one Colour must have at least .
Worked Example. Prove that in any group of people, there are at least two who have shaken Hands with the same number of people (within the group).
Solution
Each person can shake hands with between 0 and others, giving possible values. But the Values 0 and cannot both occur (if someone shook no hands, no one shook everyone’s hand, And vice versa). So there are at most distinct handshake counts among people. By the Pigeonhole principle, at least two people have the same count.
4.6 Catalan Numbers
Section titled “4.6 Catalan Numbers”The -th Catalan number is
The first few values: , , , , , .
Catalan numbers count:
- The number of valid (properly matched) sequences of pairs of parentheses.
- The number of binary search trees with nodes.
- The number of ways to triangulate a convex -gon.
- The number of lattice paths from to that never go above the diagonal.
Recurrence. and for :
Worked Example. Verify by listing all valid sequences of 3 pairs of parentheses.
Solution
The five valid sequences are: , , , , .
Checking: . ✓
4.7 Generating Functions for Combinatorics
Section titled “4.7 Generating Functions for Combinatorics”The ordinary generating function (OGF) of a sequence is
Common generating functions:
| Sequence | Generating function |
|---|---|
Key operations. If generates and generates :
- generates (choice between types).
- generates where (combining two choices).
Worked Example. Find the number of ways to select coins from unlimited supplies of 1p, 2p, And 5p coins.
Solution
The generating function is
G(x) = \underbrace{(1 + x + x^2 + \cdots)}_{\mathrm{1p\; coins{}} \cdot \underbrace{(1 + x^2 + x^4 + \cdots)}_{\mathrm{2p\; coins{}} \cdot \underbrace{(1 + x^5 + x^{10} + \cdots)}_{\mathrm{5p\; coins{}}
The coefficient of in the expansion gives the number of ways. For example, expanding the First few terms: So there are 4 ways to make 5p (5×1p; 3×1p + 1×2p; 1×1p + 2×2p; 1×5p).