Combinatorics

Introduction

Combinatorics is the mathematics of counting. How many ways can we arrange a set of objects? How many subsets does a set have? How many ways can we distribute items among recipients? These questions arise constantly in probability, computer science, and discrete mathematics.

The challenge in combinatorics is not the arithmetic—the challenge is setting up the problem correctly. The same verbal description can have vastly different answers depending on whether order matters, whether repetition is allowed, and how we define "different" arrangements.

Fundamental Counting Principles

The Multiplication Principle

If a procedure can be broken into stages, where stage 1 1 has n1 n sub 1 outcomes, stage 2 2 has n2 n sub 2 outcomes, and so on, then the total number of outcomes is:

n1×n2×⋯×nk n sub 1 times n sub 2 times dot dot dot times n sub k

The Addition Principle

If a task can be done in one of several mutually exclusive ways, with n1 n sub 1 ways for method 1 1, n2 n sub 2 ways for method 2 2, etc., then the total number of ways is:

n1+n2+⋯+nk n sub 1 plus n sub 2 plus dot dot dot plus n sub k

Permutations

A permutation is an ordered arrangement. Order matters: ABC and BAC are different permutations.

Permutations of n Distinct Objects

The number of ways to arrange n n distinct objects in a row is:

n!=n×(n−1)×(n−2)×⋯×2×1 n factorial equals n times open paren n minus 1 close paren times open paren n minus 2 close paren times dot dot dot times 2 times 1

By convention, 0 0!=1 equals 1. For example, 5 5!=120 equals 120 ways to arrange 5 5 books on a shelf.

Permutations of r Objects from n

The number of ways to choose and arrange r r objects from n n distinct objects (without replacement) is:

P⁡(n,r)=n!(n−r)!=n×(n−1)×⋯×(n−r+1) P of open paren n comma r close paren equals the fraction with numerator n factorial and denominator open paren n minus r close paren factorial equals n times open paren n minus 1 close paren times dot dot dot times open paren n minus r plus 1 close paren

Combinations

A combination is an unordered selection. Order does not matter: choosing {A,B,C} the set A comma B comma C is the same as choosing {C,B,A} the set C comma B comma A.

Choosing r from n

The number of ways to choose r r objects from n n distinct objects (without replacement, order irrelevant) is the binomial coefficient:

C⁡(n,r)=(nr)=n!r!⁢(n-r)! C of open paren n comma r close paren equals the 2 by 1 column matrix n r equals the fraction with numerator n factorial and denominator r factorial open paren n minus r close paren factorial

The formula comes from dividing the permutation count by r! r factorial to account for the r! r factorial ways of arranging each selection.

Properties of Binomial Coefficients

Symmetry: (nr)=(nn-r) the 2 by 1 column matrix n r equals the 2 by 1 column matrix Row 1: n Row 2: n minus r Choosing r r items is equivalent to choosing n−r n minus r items to exclude.

Pascal's Identity: (nr)=(n-1r-1)+(n-1r) the 2 by 1 column matrix n r equals the 2 by 1 column matrix Row 1: n minus 1 Row 2: r minus 1 plus the 2 by 1 column matrix Row 1: n minus 1 Row 2: r This recursion builds Pascal's Triangle.

Row Sum: ∑r=0n(nr)=2n the sum from r equals 0 to n of the 2 by 1 column matrix n r equals 2 to the n-th power This counts all subsets of an n nelement set.

The Binomial Theorem

The binomial theorem expands powers of a binomial:

(x+y)n=∑k=0n((nk)⁢xn-k⁢yk) open paren x plus y close paren to the n-th power equals the sum from k equals 0 to n of open paren the 2 by 1 column matrix n k times x raised to the n minus k power y to the k-th power close paren

Each term (nk)⁢xn-k⁢yk the 2 by 1 column matrix n k times x raised to the n minus k power y to the k-th power counts the number of ways to choose k k factors of y y from the n n factors of (x+y) open paren x plus y close paren

Permutations with Repetition

When arranging objects where some are identical, divide by the factorial of each group's size. For objects with n1 n sub 1 of type 1, n2 n sub 2 of type 2, etc.:

n!n1!⋅n2!⋅…⋅nk! the fraction with numerator n factorial and denominator n sub 1 factorial times n sub 2 factorial times dot dot dot times n sub k factorial

Stars and Bars

The stars and bars method counts the number of ways to distribute n n identical objects into k k distinct bins.

The number of ways to distribute n n identical items into k k distinct bins (allowing empty bins) is: (n+k-1k-1)=(n+k-1n) the 2 by 1 column matrix Row 1: n plus k minus 1 Row 2: k minus 1 equals the 2 by 1 column matrix Row 1: n plus k minus 1 Row 2: n

The idea: represent the distribution as a sequence of n n stars (items) and k−1 k minus 1 bars (dividers). We choose positions for the bars among the n+k−1 n plus k minus 1 total positions.

Summary Table

Ordered, no repetition (permutation): P⁡(n,r)=n!(n−r)! P of open paren n comma r close paren equals the fraction with numerator n factorial and denominator open paren n minus r close paren factorial

Ordered, with repetition: nr n to the r-th power

Unordered, no repetition (combination): C⁡(n,r)=(nr)=n!r!⁢(n-r)! C of open paren n comma r close paren equals the 2 by 1 column matrix n r equals the fraction with numerator n factorial and denominator r factorial open paren n minus r close paren factorial

Unordered, with repetition (multiset): (n+r-1r) the 2 by 1 column matrix Row 1: n plus r minus 1 Row 2: r

Connection to Other Concepts

Combinatorics is essential for probability. The probability of an event is often computed as (favorable outcomes) / (total outcomes), both of which require counting.

The binomial coefficient (nk) the 2 by 1 column matrix n k appears in the binomial distribution, where it counts the number of ways to get exactly k k successes in n n trials.

In algorithm analysis, combinatorics determines the number of inputs, iterations, or operations. The complexity of many algorithms depends on combinatorial quantities.

Summary

Combinatorics provides systematic methods for counting arrangements and selections. The key distinction is between permutations (order matters) and combinations (order doesn't matter), and between sampling with or without repetition.

The binomial coefficient (nr) the 2 by 1 column matrix n r counts combinations and appears in the binomial theorem for expanding (x+y)n open paren x plus y close paren to the n-th power The multiplication and addition principles are the foundation for more complex counting arguments.

The challenge in combinatorics is recognizing which counting principle applies to a given problem. Practice and careful analysis of what "different" means in each context are essential.