07 Advanced Counting Methods

A progressive guide to choosing and applying binomial coefficients, the binomial theorem, inclusion-exclusion, and recurrence relations in advanced counting problems.

Recognizing the Structure of a Counting Problem

Advanced counting becomes manageable when the same objects can be described through complementary viewpoints: selecting a subset, expanding a power, correcting overlaps, or building larger objects from smaller ones. The first step is to identify what is being counted and whether order, repetition, overlap, or local restrictions matter.

A useful decision process is:

  1. Select a fixed number of distinct objects with order irrelevant: use a .

  2. Expand a power or extract one coefficient: use the .

  3. Count objects satisfying at least one of several overlapping properties, or avoiding all listed restrictions: use inclusion-exclusion.

  4. Construct objects by extending smaller valid objects: derive a .

  5. Distribute identical units among distinguishable categories: consider .

The central habit is to describe the objects in a way that prevents omission and overcounting.

Takeaway: Choose the method from the structure of the objects, not merely from the size of the numbers.

Selecting Objects and Distributing Repetitions

When choosing an unordered collection of kk objects from nn distinct objects, the number of choices is

(nk)=n!k!(n−k)!.\binom{n}{k}=\frac{n!}{k!(n-k)!}.

The factorials account for all arrangements while the denominator removes the ordering of the selected and unselected objects. For example, a committee of three chosen from eight people has

(83)=8!3!5!=56\binom{8}{3}=\frac{8!}{3!5!}=56

possible memberships.

Two identities make computation and reasoning easier:

  • Symmetry: (nk)=(nn−k)\binom{n}{k}=\binom{n}{n-k}. Choosing what is included is equivalent to choosing what is left out.

  • Pascal's identity: (nk)=(n−1k−1)+(n−1k)\binom{n}{k}=\binom{n-1}{k-1}+\binom{n-1}{k}. Separate selections according to whether a distinguished object is included.

Summing every possible subset size gives

∑k=0n(nk)=2n,\sum_{k=0}^{n}\binom{n}{k}=2^n,

because each of the nn elements is independently included or excluded.

When repetition is allowed, the situation changes. The number of ways to select kk objects from nn types is

(n+k−1k).\binom{n+k-1}{k}.

For instance, the nonnegative integer solutions of x1+x2+x3=7x_1+x_2+x_3=7 number

(92)=36.\binom{9}{2}=36.

Takeaway: Use ordinary binomial coefficients for distinct objects without order, and when identical units may be repeated across distinguishable types.

Expanding Powers and Extracting Coefficients

The organizes the expansion of a power:

(x+y)n=∑k=0n(nk)xn−kyk.(x+y)^n=\sum_{k=0}^{n}\binom{n}{k}x^{n-k}y^k.

The coefficient appears because a term containing kk copies of yy is formed by choosing which kk of the nn factors contribute yy; every remaining factor contributes xx.

For example,

(x+y)4=x4+4x3y+6x2y2+4xy3+y4.(x+y)^4=x^4+4x^3y+6x^2y^2+4xy^3+y^4.

Coefficient extraction is often faster than full expansion. The coefficient of x5y3x^5y^3 in (x+y)8(x+y)^8 is

(83)=56.\binom{8}{3}=56.

Two substitutions reveal important counting identities:

  • Setting x=y=1x=y=1 gives 2n=∑k=0n(nk)2^n=\sum_{k=0}^{n}\binom{n}{k}.

  • Setting x=1x=1 and y=−1y=-1 gives ∑k=0n(−1)k(nk)=0\sum_{k=0}^{n}(-1)^k\binom{n}{k}=0 for n≥1n\ge 1.

The second identity reflects cancellation between even-sized and odd-sized selections and is closely connected to inclusion-exclusion.

Takeaway: Match the requested monomial to the number of factors contributing one of its variables; the corresponding is its coefficient.

Correcting Overlaps with Inclusion-Exclusion

The corrects the overcounting caused by overlaps. For two finite sets,

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣.|A\cup B|=|A|+|B|-|A\cap B|.

The intersection is subtracted because its elements were counted twice. For three sets, add the three individual counts, subtract the three pairwise intersections, and add the triple intersection.

In general,

∣⋃i=1nAi∣=∑∅≠I⊆{1,…,n}(−1)∣I∣+1∣⋂i∈IAi∣.\left|\bigcup_{i=1}^{n}A_i\right| = \sum_{\varnothing\ne I\subseteq\{1,\ldots,n\}} (-1)^{|I|+1} \left|\bigcap_{i\in I}A_i\right|.

To count objects that avoid every restriction, let AiA_i be the objects violating restriction ii. Then subtract their union from the whole set:

∣⋂i=1nAic∣=∣S∣−∣⋃i=1nAi∣.\left|\bigcap_{i=1}^{n}A_i^c\right| =|S|-\left|\bigcup_{i=1}^{n}A_i\right|.

For example, among the integers from 11 through 100100, the counts divisible by 22, 33, or 55 are 5050, 3333, and 2020. Their pairwise intersection counts are 1616, 1010, and 66, and the triple intersection count is 33. Therefore,

50+33+20−16−10−6+3=74.50+33+20-16-10-6+3=74.

A derangement is a permutation in which no object remains in its original position. If DnD_n counts derangements of nn objects, inclusion-exclusion gives

Dn=n!∑k=0n(−1)kk!.D_n=n!\sum_{k=0}^{n}\frac{(-1)^k}{k!}.

Takeaway: List overlaps by intersection size and alternate signs: add singles, subtract pairs, add triples, and continue.

Building and Solving Recurrences

A is effective when valid objects can be partitioned into disjoint cases based on a first step, final step, or distinguished component. The cases must be exhaustive and disjoint, and the recurrence must be accompanied by initial conditions.

For binary strings of length nn with no consecutive 11s, inspect the final digit. Strings ending in 00 contribute an−1a_{n-1}; strings ending in 11 must have a preceding 00, leaving an−2a_{n-2} possibilities. Thus,

an=an−1+an−2,a0=1,a1=2.a_n=a_{n-1}+a_{n-2},\qquad a_0=1,\quad a_1=2.

For tilings of a 2×n2\times n board with 2×12\times1 dominoes, the leftmost portion is either one vertical domino or two horizontal dominoes. This gives

tn=tn−1+tn−2,t0=1,t1=1.t_n=t_{n-1}+t_{n-2},\qquad t_0=1,\quad t_1=1.

Some recurrences can be unrolled directly. If

bn=bn−1+n,b0=4,b_n=b_{n-1}+n,\qquad b_0=4,

then

bn=4+1+2+⋯+n=4+n(n+1)2.b_n=4+1+2+\cdots+n=4+\frac{n(n+1)}{2}.

For a second-order homogeneous recurrence, try an=rna_n=r^n. The resulting determines the possible exponential terms. If the roots are distinct, the general form is

an=Ar1n+Br2n,a_n=Ar_1^n+Br_2^n,

with constants fixed by the initial conditions. For the Fibonacci recurrence, the roots are

φ=1+52,ψ=1−52,\varphi=\frac{1+\sqrt{5}}{2},\qquad \psi=\frac{1-\sqrt{5}}{2},

which leads to

Fn=φn−ψn5.F_n=\frac{\varphi^n-\psi^n}{\sqrt{5}}.

For a nonhomogeneous recurrence such as an=3an−1+2a_n=3a_{n-1}+2, solve the associated homogeneous recurrence, find a particular solution, combine them, and then apply the initial condition. A constant particular solution satisfies p=3p+2p=3p+2, so p=−1p=-1, giving the general form an=C3n−1a_n=C3^n-1.

Takeaway: First find a sound case split; only then perform the algebra needed to solve the resulting recurrence.