Combinatorics

Counting Rules and Techniques

Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures.

Learning Objectives

Describe the different rules and properties for combinatorics

Key Takeaways

Key Points

  • The rule of sum (addition rule), rule of product (multiplication rule), and inclusion-exclusion principle are often used for enumerative purposes.
  • Bijective proofs are utilized to demonstrate that two sets have the same number of elements.
  • Double counting is a technique used to demonstrate that two expressions are equal. The pigeonhole principle often ascertains the existence of something or is used to determine the minimum or maximum number of something in a discrete context.
  • Generating functions and recurrence relations are powerful tools that can be used to manipulate sequences, and can describe if not resolve many combinatorial situations.
  • Double counting is a technique used to demonstrate that two expressions are equal.


Key Terms

  • polynomial: An expression consisting of a sum of a finite number of terms: each term being the product of a constant coefficient and one or more variables raised to a non-negative integer power.
  • combinatorics: A branch of mathematics that studies (usually finite) collections of objects that satisfy specified criteria.


Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures. Combinatorial techniques are applicable to many areas of mathematics, and a knowledge of combinatorics is necessary to build a solid command of statistics. It involves the enumeration, combination, and permutation of sets of elements and the mathematical relations that characterize their properties.

Aspects of combinatorics include: counting the structures of a given kind and size, deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria. Aspects also include finding "largest," "smallest," or "optimal" objects, studying combinatorial structures arising in an algebraic context, or applying algebraic techniques to combinatorial problems.

Combinatorial Rules and Techniques

Several useful combinatorial rules or combinatorial principles are commonly recognized and used. Each of these principles is used for a specific purpose. The rule of sum (addition rule), rule of product (multiplication rule), and inclusion-exclusion principle are often used for enumerative purposes. Bijective proofs are utilized to demonstrate that two sets have the same number of elements. Double counting is a method of showing that two expressions are equal. The pigeonhole principle often ascertains the existence of something or is used to determine the minimum or maximum number of something in a discrete context. Generating functions and recurrence relations are powerful tools that can be used to manipulate sequences, and can describe if not resolve many combinatorial situations. Each of these techniques is described in greater detail below.

Rule of Sum

The rule of sum is an intuitive principle stating that if there are
aa
 possible ways to do something, and
bb
possible ways to do another thing, and the two things can't both be done, then there are
a+ba + b
total possible ways to do one of the things. More formally, the sum of the sizes of two disjoint sets is equal to the size of the union of these sets.

Rule of Product

The rule of product is another intuitive principle stating that if there are
aa
ways to do something and
bb
ways to do another thing, then there are
aba \cdot b
ways to do both things.

Inclusion-Exclusion Principle

The inclusion-exclusion principle is a counting technique that is used to obtain the number of elements in a union of multiple sets. This counting method ensures that elements that are present in more than one set in the union are not counted more than once. It considers the size of each set and the size of the intersections of the sets. The smallest example is when there are two sets: the number of elements in the union of
AA
and
BB
is equal to the sum of the number of elements in
AA
and
BB
, minus the number of elements in their intersection. See the diagram below for an example with three sets.

Bijective Proof

A bijective proof is a proof technique that finds a bijective function
f:ABf: A \rightarrow B
between two finite sets
AA
and
BB
, which proves that they have the same number of elements,
A=B|A| = |B|
. A bijective function is one in which there is a one-to-one correspondence between the elements of two sets. In other words, each element in set
BB
is paired with exactly one element in set
AA
. This technique is useful if we wish to know the size of
AA
, but can find no direct way of counting its elements. If
BB
is more easily countable, establishing a bijection from
AA
to
BB
solves the problem.

Double Counting

Double counting is a combinatorial proof technique for showing that two expressions are equal. This is done by demonstrating that the two expressions are two different ways of counting the size of one set. In this technique, a finite set
XX
is described from two perspectives, leading to two distinct expressions for the size of the set. Since both expressions equal the size of the same set, they equal each other.

Pigeonhole Principle

The pigeonhole principle states that if
aa
items are each put into one of
bb
boxes, where
a>ba>b
, then at least one of the boxes contains more than one item. This principle allows one to demonstrate the existence of some element in a set with some specific properties. For example, consider a set of three gloves. In such a set, there must be either two left gloves or two right gloves (or three of left or right). This is an application of the pigeonhole principle that yields information about the properties of the gloves in the set.

Generating Function

Generating functions can be thought of as polynomials with infinitely many terms whose coefficients correspond to the terms of a sequence. The (ordinary) generating function of a sequence
ana_n
is given by:

f(x)=n=0anxn\displaystyle f(x) = \sum_{n=0}^{\infty} a_{n}x^{n}


whose coefficients give the sequence
{a0,a1,a2,...}\left \{ a_{0}, a_{1}, a_{2},... \right \}
.

Recurrence Relation

A recurrence relation defines each term of a sequence in terms of the preceding terms. In other words, once one or more initial terms are given, each of the following terms of the sequence is a function of the preceding terms.

The Fibonacci sequence is one example of a recurrence relation. Each term of the Fibonacci sequence is given by
Fn=Fn1+Fn2F_{n} = F_{n-1} + F_{n-2}
, with initial values
F0=0F_{0}=0
and
F1=1F_{1}=1
. Thus, the sequence of Fibonacci numbers begins:

0,1,1,2,3,5,8,13,21,34,55,89,...\displaystyle 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...


Permutations

A permutation of a set of objects is an arrangement of those objects in a particular order; the number of permutations can be counted.

Learning Objectives

Calculate the number of arrangements of ordered objects using permutations

Key Takeaways

Key Points

  • Informally, a permutation of a set of objects is an arrangement of those objects into a particular order. For example, there are six permutations of the set
    1,2,3{1,2,3}
    , namely
    (1,2,3)(1,2,3)
    ,
    (1,3,2)(1,3,2)
    ,
    (2,1,3)(2,1,3)
    ,
    (2,3,1)(2,3,1)
    ,
    (3,1,2)(3,1,2)
    , and
    (3,2,1)(3,2,1)
    .
  • The number of permutations of
    nn
    distinct objects is
    n(n1)(n2)21n \cdot (n - 1) \cdot (n - 2) \cdots 2 \cdot 1
    . This is called
    nn
    factorial, and written
    n!n!
    .
  • When deciding permutations of a subset from a larger set, it is often useful to divide one factorial by another to determine the number of permutations possible. For example, the first six cards from a deck of cards would have
    52!46!\frac {52!}{46! }
    permutations possible, or about 14.7 billion.


Key Terms

  • factorial: The result of multiplying a given number of consecutive integers from
    11
    to the given number. In equations, it is symbolized by an exclamation mark (
    !!
    ). For example,
    5!=12345=1205! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120
    .
  • permutation: An ordering of a finite set of distinct elements.


Permutations

A permutation of a set of objects is an arrangement of those objects into a particular order. For example, there are six permutations of the set
1,2,3{1,2,3}
:
(1,2,3)(1,2,3)
,
(1,3,2)(1,3,2)
,
(2,1,3)(2,1,3)
,
(2,3,1)(2,3,1)
,
(3,1,2)(3,1,2)
, and
(3,2,1)(3,2,1)
. One might define an anagram of a word as a permutation of its letters.

image The 6 permutations of 3 balls: If one has three different colored balls, there are six distinct ways to order them, as shown. These six distinct orderings are as follows: red-green-blue, red-blue-green, green-red-blue, green-blue-red, blue-red-green, and blue-green-red.


The number of permutations of

nn
distinct objects is given by:

n(n1)(n2)21\displaystyle n \cdot (n - 1) \cdot (n - 2) \cdots 2 \cdot 1


This is called
nn
factorial and is written
n!n!
.

In other words, a factorial is to multiply all the numbers from
11
up to this number. So
5!5!
means
12345=1201 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120
. Thus,
120120
is the number of permutations possible for a set of five distinct objects.

Example

In the game of Solitaire, seven cards are dealt out at the beginning: one face-up, and the other six face-down. A complete card deck has
5252
cards. Assuming that the only card that is seen is the
77
 of spades, how many possible "hands" (the other six cards) can be underneath? What makes this a permutation problem is that the order matters: if an ace is hiding somewhere in those six cards, it makes a difference whether the ace is on the first position, the second, etc. Permutation problems can always be addressed as an example of the multiplication rule, with one small twist.

image One stack of cards in a game of solitaire: To find out how many possible combinations of cards there are below the seven of spades, we use the concept of permutations to calculate the possible arrangements of cards.


How many cards might be in the first position, directly under the showing

77
? The answer is 51. That card can be anything except the
77
of spades.

If any given card is in the first position, how many cards might be in second position? The answer is
5050
. The seven of spades and the next card have both been dealt. So there are possible cards left for the second position.

So how many possibilities are there for the first two positions combined? The answer is
515051 \cdot 50
.

How many possibilities are there for all six positions? The answer is
51504948474651 \cdot 50 \cdot 49 \cdot 48 \cdot 47 \cdot 46
, or approximately
1.310101.3 \cdot 10^{10}
; about
1313
billion possibilities!

This result can be expressed more concisely by using factorials.

Note that
7!5!\frac {7!}{5! }
 can also be written as
123456712345\frac {1\cdot 2\cdot 3\cdot 4\cdot 5\cdot 6\cdot 7}{1\cdot 2\cdot 3\cdot 4\cdot 5}
. Most of the terms cancel, leaving only
6×7=426×7=42
.

Consider another example,
51!45!\frac {51!}{45! }
. If all of the terms are written out, the first
4545
terms cancel, leaving
46474849505146 \cdot 47 \cdot 48 \cdot 49 \cdot 50 \cdot 51
in the numerator. Instead of typing into a calculator six numbers to multiply, or sixty numbers or six hundred depending on the problem, the answer to a permutation problem can be found by dividing two factorials. In many calculators, the factorial option is located under the "probability" menu for this reason.

General Considerations

In mathematics, the notion of permutation is used with several slightly different meanings, all related to the act of permuting (rearranging) objects or values. Informally, a permutation of a set of objects is an

arrangement of those objects into a particular order. The study of permutations generally belongs to the field of combinatorics.

Permutations occur, in more or less prominent ways, in almost every domain of mathematics. They often arise when different orderings on certain finite sets are considered, possibly only because one wants to ignore such orderings and needs to know how many configurations are thus identified. For similar reasons, permutations arise in the study of sorting algorithms in computer science.

Permutations of Distinguishable Objects

The number of permutations of distinct elements can be calculated when not all elements from a given set are used.

Learning Objectives

Calculate the number of permutations of
nn
objects taken
kk
at a time

Key Takeaways

Key Points

  • If all objects in consideration are distinct, they can be arranged in
    n!n!
    permutations, where
    nn
    represents the number of objects.
  • If not all the objects in a set of
    nn
    unique elements are chosen, the above formula can be modified to:
    n!(nk)!\displaystyle \frac {n!}{(n-k)! }
    , where
    kk
    represents the number of selected elements.
  • When solving for quotients of factorials, the terms of the denominator can cancel with the terms of the numerator, thus eliminating perhaps the majority of terms to be multiplied.


Key Terms

  • factorial: The result of multiplying a given number of consecutive integers from
    11
    to the given number. In equations, it is symbolized by an exclamation mark (
    !!
    ). For example,
    5!=12345=1205! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120
    .
  • permutation: An ordering of a finite set of distinct elements.


Recall that, if all objects in a set are distinct, then they can be arranged in
n!n!
possible permutations, where
nn
represents the number of objects. The quantity
n!n!
is given by:

n(n1)(n2)21\displaystyle n\cdot (n-1)\cdot (n-2)\cdots 2\cdot 1


It is easy enough to use this formula to count the number of possible permutations of a set of distinct objects; for example, the number of permutations of three differently-colored balls. However, consider a situation where not all of the elements in a set of distinct objects are used in each permutation. For example, what if
77
cards are chosen from among a full deck of
5252
? In this case, not all of the cards from the deck are chosen for each possible permutation. There exists a formula for solving permutation problems such as this one, which would otherwise be nearly impossible to determine.

Permutations of a Partial Set

If not all of the objects in a set of unique elements are chosen, the following formula is used. This formula determines the number of possible permutations of
kk
elements selected from the set of
nn
elements:

n!(nk)!\displaystyle \frac {n!}{(n-k)! }


To understand the application of this concept, consider a race in which
33
 different prizes are awarded to the top
33
fastest competitors. If
2525
competitors participate in the race, in how many distinct orders could the
33
prizes be awarded?

To solve this problem, we want to evaluate the number of possible permutations of 
33
elements from the set of
2525
 elements; in other words,
k=3k = 3
and
n=25n=25
. Plugging these values into the formula, we have:

25!(253)!=25!22!\displaystyle \frac {25!}{(25-3)! } = \frac {25!}{22!}


Remember that both
25!25!
and
22!22!
contain the terms
22212122 \cdot 21 \cdots 2 \cdot 1
. Thus, these values cancel from the numerator and denominator, and the equation can be simplified:



25!22!=252423222121222121=252423=13,800 \displaystyle \begin{align} \frac{25!}{22!} &= \frac{25 \cdot 24 \cdot 23 \cdot 22 \cdot 21 \cdots 2 \cdot 1}{22 \cdot 21 \cdots 2 \cdot 1} \\ &= 25 \cdot 24 \cdot 23 \\ &= 13,800 \end{align}


There are
13,80013,800
possible permutations in which the
33
top prizes may be awarded to the
2525
race competitors.

General Considerations

It is worth noting that this formula does not exclude what we might call 'duplicate' permutations. In other words, the order of the elements selected does matter. Consider
33
 cards drawn from a pack: an ace of spades, a
1010
of diamonds, and a
33
of clubs. The hand is exactly the same as the following: a
1010
of diamonds, an ace of spaces and a
33
of clubs. If you are playing a game in which the order of your cards does not matter, you will only want to count each permutation of cards once. The formula introduced here does not apply to such situations.



Permutations of Nondistinguishable Objects

The expression revealing the number of permutations of distinct items can be modified if not all items in the set are distinct.

Learning Objectives

Calculate the number of permutations of a given set of objects, some being non distinguishable

Key Takeaways

Key Points

  • Some sets include repetitions of certain elements. In these cases, the number of possible permutations of the items cannot be expressed by
    n!n!
    , where
    nn
    represents the number of elements, because this calculation would include a multiplicity of possible states.
  • To correct for the multiplicity of certain permutations, divide the factorial of the total number of elements by the product of the factorials of the number of each repeated element.
  • The expression for number of permutations with repeated elements is:
    n!n1!n2!n3!...\frac {n!}{n_1!n_2!n_3!... }
     where
    nn
    is the total number of terms in a sequence and
    n1n_1
    ,
    n2n_2
    , and
    n3n_3
    are the number of repetitions of different elements.


Key Terms

  • multiplicity: The number of values for which a given condition holds.
  • permutation: An ordering of a finite set of distinct elements.


Recall that the number of possible permutations of a set of
nn
distinct elements is given by
n!n!
:

n(n1)(n2)21\displaystyle n \cdot (n-1) \cdot(n-2) \cdots 2 \cdot 1


This can be easily tested. The number
11
 can be arranged in just one
1!1!
 way. The numbers
11
and
22
can be arranged in two
2!2!
ways:
(1,2)(1,2)
and
(2,1)(2,1)
. The numbers
11
,
22
, and
33
can be arranged in
3!3!
ways:
(1,2,3)(1,2,3)
,
(1,3,2)(1,3,2)
,
(2,1,3)(2,1,3)
,
(2,3,1)(2,3,1)
,
(3,1,2)(3,1,2)
, and
(3,2,1)(3,2,1)
. This rule holds true for sets of any size, so long as the elements are all distinct. But what if some elements are repeated?

Repetition of some elements complicates the calculation of permutations, because it allows for there to be multiple ways in which a specific order of elements can be arranged. For example, given the numbers
11
,
33
, and
33
in a set, there are 2 ways to obtain the order
(3,1,3)(3,1,3)
.

To correct for the "multiplicity" of certain permutations, we must divide the factorial of the total number of elements by the product of the factorials of the number of each repeated element. This can generally be represented as:

n!n1!n2!n3!...\displaystyle \frac {n!}{n_1!n_2!n_3!... }


Where
nn
is the total number of terms in a sequence, and
n1n_1
,
n2n_2
, and
n3n_3
represent the number of repetitions of different elements.

To understand why we would divide by the number of repetitions, consider that
22
elements can be arranged in a total of
2!2!
distinct ways,
33
elements can be arranged in a total of
3!3!
distinct ways, and so on. When we encounter multiplicity in a permutation, we must account for it by dividing these possible arrangements out of the total number of permutations that would be possible if all of the elements were distinct.

Example: Consider the set of numbers:

(15,17,24,24,28)\displaystyle (15, 17, 24, 24, 28)


There are five terms, so
n=5n=5
. However, two of the terms are the same; their value is
2424
. Thus, the number of possible distinct permutations in the set is:

5!2!=60\displaystyle{\frac {5!}{2! }=60}


The same logic can apply to more complicated systems.

Example: Consider the set:

(0,0,0,2,4,4,7,7,7,7,7,8,8)\displaystyle (0, 0, 0, 2, 4, 4, 7, 7, 7, 7, 7, 8, 8)


In total, there are
1313
elements. These include many repetitions:
00
 is seen 3 times,
44
and
88
each are observed twice, and there are
55
instances of the number
77
. Thus, the number of possible distinct permutations can be calculated by:

13!2!2!3!5!=2,162,160\displaystyle \frac {13! }{2!\cdot 2!\cdot 3!\cdot 5! }= 2,162,160


This logic can be applied to problems involving anagrams of given words.

Example: Consider how many distinct ways you can order the letters of the word "waterfall."

The word waterfall consists of
99
letters in total, so
n=9n=9
. The letter "a" appears twice, giving a value of
22
for
n1n_{1}
. Similarly, the letter "l" appears twice, yielding
n2=2n_{2} = 2
. Thus, the number of distinct permutations for the letters in "waterfall" can be calculated as:

9!2!2!=90,720\displaystyle \frac {9! }{2!\cdot 2!}= 90,720


Combinations

A combination is a way of selecting several things out of a larger group, where (unlike permutations) order does not matter.

Learning Objectives

Calculate the number of ways of selecting several things out of a larger group (where order doesn't matter) using combinations

Key Takeaways

Key Points

  • A combination is a mathematical concept where one counts the number of ways one can select several elements out of a larger group.
  • Unlike a permutation, when determining the number of combinations, order does not matter.
  • Formally, a
    kk
    -combination of a set
    SS
    is a subset of
    kk
    distinct elements of
    SS
    . If the set has
    nn
    elements the number of
    kk
    -combinations is equal to the binomial coefficient:
    (nk)=n(n1)...(nk+1)k(k1)...1\begin{pmatrix} n\\ k \end{pmatrix} = \frac {n(n-1)...(n-k+1)}{k(k-1)...1}
    , which can be written using factorials as
    n!k!(nk)!\frac {n!}{k!(n-k)! }
    whenever
    knk \le n
    and which is zero when
    k>nk > n
    .


Key Terms

  • combination: A way of selecting elements from a set, where order does not matter.
  • binomial coefficient: A coefficient of any of the terms in the expansion of the binomial power
    (1+x)n(1+x)^n
    .


In mathematics, a combination is a way of selecting several things out of a larger group, where (unlike permutations) order does not matter. In smaller cases, it is possible to count the number of combinations. For example, given
33
 pieces of fruit: an apple, an orange and a pear. There are
33
combinations of
22
that can be drawn from this set: an apple and a pear, an apple and an orange, or a pear and an orange.

Combinations can refer to the combination of
nn
things taken
kk
at a time with or without repetition. In the above example, repetition was not allowed. If, however, it was possible to have
22
of any
11
kind of fruit there would be
33
 more combinations:
22
 apples,
22
oranges, and
22
pears.

To understand the difference between a permutation and combination, consider a deck of
5252
cards, from which a poker hand (
55
cards) is dealt. How many possible poker hands are there?

At first glance, this may seem like a permutation question, where one might consider how many distinct ways there are to make a stack of cards. However, there is one important difference: order does not matter in this problem. When dealt a poker hand during a game, order does not matter so you will have the same hand regardless of the order in which the cards are dealt. Combination problems involve such scenarios.

To approach such a question, begin with the permutations: how many possible poker hands are there, if order does matter?

Recall the permutation formula:
n!(nk)!\displaystyle{\frac{n!}{(n-k)!}}
, where
nn
is the number of distinct objects in the set, and
kk
is the number of objects selected. In this case, we can calculate the number of permutations as:

 
52!(525)!=52!47!=5251504948\displaystyle \begin{align} \frac{52!}{(52-5)!}&=\frac{52!}{47!}\\ &=52 \cdot 51 \cdot 50 \cdot 49 \cdot 48 \end{align}


This yields approximately
311.9311.9
million possible poker hands. However, one has to count every possible hand many different times in this calculation. How many different times is one counting each distinct hand?

The key insight is that this second question—"How many different times is one counting each distinct hand?" is itself a permutation question. It is the same as the question "How many different ways can these five cards be rearranged in a hand?" There are
55
possibilities for the first card,
44
for the second, and so on. The answer is
5!5!
, which is
120120
. So, since every possible hand has been counted
120120
times, divide our earlier result by
120120
to find that there are
52!(47!)(5!)\frac {52!}{(47!)(5! )}
, or about
2.62.6
million possible poker hands.

Combinations turn out to have a surprisingly large number of applications. Consider the following questions:

  • A school offers
    5050
    classes. Each student must choose
    66
     of them to fill out a schedule. How many possible schedules can be made?
  • A basketball team has
    1212
     players, but only
    55
    will start. How many possible starting teams can they field?
  • Your computer contains
    300300
    videos, but you can only fit
    1010
     of them on your phone. How many possible ways can you load your phone?


Each of these is a combinations question, and can be answered exactly like the card scenario. Since this type of question comes up in so many different contexts, it is given a special name and symbol. The last question would be referred to as "
300300
choose
1010
" and written
(30010)\begin{pmatrix} 300\\ 10 \end{pmatrix}
. It is calculated as
300!(290!)(10!)\frac {300!}{(290!)(10! )}
, for reasons explained above.

Each possible combination of
kk
distinct elements of a set
SS
is known as a
kk
-combination. If the set has
nn
elements, the number of
kk
-combinations is equal to

(nk)=n(n1)...(nk+1)k(k1)...1\begin{pmatrix} n\\ k \end{pmatrix} = \dfrac {n(n-1)...(n-k+1)}{k(k-1)...1}


Which can be written using factorials as

n!k!(nk)!\dfrac {n!}{k!(n-k)! }


Whenever
knk \leq n
, and which is zero when
k>nk > n
. The set of all
kk
-combinations of a set
SS
is often denoted by
(Sk)\begin{pmatrix} S \\ k \end{pmatrix}
, which is read as "
SS
choose
kk
," such as in the phone example above. The set of
kk
-combinations may also be denoted in certain texts by
C(n,k)C(n,k)
, or by a variation such as
CknC_k^n
,
nCk_nC_k
, or
nCk^nC_k
.

General Considerations

The number of
kk
-combinations, or
(Sk)\begin{pmatrix} S \\ k \end{pmatrix}
, is also known as the binomial coefficient, because it occurs as a coefficient in the binomial formula. The binomial coefficient is the coefficient of the
xkx^k
term in the polynomial expansion of
(1+x)n(1+x)^n


Licenses and Attributions

More Study Resources for You

Show More