Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Combinatorics

In the last section we saw how to count the number of subsets of a set (2n) and the
number of ordered pairs from two sets (m  n). This sort of counting is more
sophisticated than the basic counting by repeated succession that we learned in the very
first section.
The area of mathematics that deals with more sophisticated counting questions is called
combinatorics. Since advanced counting is useful when trying to judge the complexity
of an information processing task, we will take this section to learn a little more of this
advanced counting.

Question How many ways are there to arrange three letters in a row without repeating a
letter?

Answer Let’s suppose that the three letters are a, b, and c. We could try making a list of
all the possibilities:
abc
acb
bac
bca
cab
cba
and we would find six possible ways to arrange the three letters in a row.
But we can save ourselves the trouble of trying to make a list if we think a little first. To
arrange the three letters in a row, we have to make a choice of some letter, either a, b, or c
to write first. For each of these 3 choices there are only 2 choices left for the second
letter, so altogether there are 3 x 2 choices for the first two letters. Once we’ve chosen
the first two letters there is only once letter left to choose third, so altogether we have
3x2x1, or 6, possibilities.

Question How many ways are there to arrange seven letters in a row with no
repetitions?

Answer Following the reasoning in the last example, there are 7 choices for the first
letter and then 6 choices left for the second, giving us so far 7x6. After that there are 5
choices for the third letter (so far we have 7x6x5). Continuing on this way until we are
left with 7x6x5x4x3x2x1 possible ways to arrange seven letters in a row. Multiply
7x6x5x4x3x2x1 gives 5040. We certainly wouldn’t want to try to make a list of all of
these possibilities!

Numbers like 7x6x5x4x3x2x1 come up often enough that there is a notation for them that
is commonly used. We say 7x6x5x4x3x2x1 is 7 factorial and we write 7! for short.
Similarly, 3 factorial is 3! = 3x2x1,
9 factorial is 9! = 9x8x7x6x5x4x3x2x1,
23 factorial is 23! = 23x22x21x20x19x … x5x4x3x2x1.
Suppose now that we have a bunch of letters, but we only want to arrange just some of
them in a row.

Question How many ways can you arrange 3 letters in a row (with no repetitions) if you
have 7 letters to choose from?

Answer The reasoning is similar to the previous answers, but here we have more letters
than there are places to put them. We start with 7 possibilities for the first letter and 6
remaining letters for the second choice (so far we have 7x6, or 42). For each of these 42
possibilities there are 5 letters remaining for the third choice. So altogether we have
7x6x5 ways.

The last answer is different from the previous answers in that we didn’t have to carry the
multiplication all the way down to 1. But we can still use factorial notation to express the
answer, saving us the trouble of writing out all of the multiplication. The trick is to write

7 x6 x5 x 4 x3 x 2 x1 7!
7x6x5 = =
4 x3 x 2 x1 4!

The first equation is true because the 4x3x2x1 in the numerator and the 4x3x2x1 in the
denominator cancel out, leaving us with just 7x6x5. Now we can write the entire
numerator as 7! and the denominator as 4!, giving us the fraction on the right. How do
we know to use 4 as the factorial in the denominator? It’s because 4 is what’s left after
we’ve used up 3 letters out of the 7 (i.e. 4 = 7-3). So another way we could have written
the right hand side is
7!
(7  3)!
This trick works in general. For example,

Question How many ways can you arrange 4 letters in a row (with no repetitions) from
a set of 9 letters?

Answer Again, 9 for the first, 8 for the second, 7 for the third, 6 for the fourth makes
9x8x7x6, which can be written
9! 9!
which is also .
5! (9  4)!

In combinatorics, an arrangement of letters in a row (with no repetitions), is called a


permutation. We’ll use the notation P(n, r) to denote the number of permutations of r
letters taken from a set of n letters. So in the last two questions we’ve seen that
7! 9!
P(7, 3) = and P(9, 4) = .
(7  3)! (9  4)!
Similar reasoning works in general to give us the following:
FACT If you have n letters to choose from, the number of ways to arrange r letters in a
row without repeating any of them is
n!
P(n, r) = .
(n  r )!
In other words, the number of permutations of r letters taken from a set of n letters is
given by the formula on the right.

Why do people study permutations? By using the formula above we can answer many
questions about the real world!

Question How many ways can you arrange 7 books on a shelf?

Answer If you label the books a, b, c, d, e, f, g then this is just a question about way
many ways you can arrange 7 letters in a row without repeating any of them. We
answered that question above and found that the answer was 7!. This is just a case of the
formula above, so we have
7!
P(7, 7) = .
(7  7)!
Here the denominator, (7 – 7)!, is the same as 0!. What does 0! mean? We can’t
multiply 0 by smaller numbers and get down to 1. But if want our formula to work
correctly, if we want
7!
7! =
(7  7)!
then we better make the following definition:

Definition 0! = 1

Here are a couple more practical examples.

Question In a race, how many ways can 7 horses come in first, second, and third?

Answer Again we recognize this as a question about permutations. We are essentially


arranging 3 letters taken from a set of 7 letters as we did above. The formula gives
7!
P(7, 3) = .
(7  3)!
and we saw above that this amounts to calculating 7x6x5 (which works out to be 210).

Question If you don’t use the same letter twice, how many passwords can you make that
are 8 letters long if you have 52 symbols (26 lowercase and 26 uppercase) letters to
choose from?

52!
Answer By now we recognize this as P(52, 8) = , though calculating this
(52  8)!
number is a bit boring without a program to do it for us! (It works out to about 3 x 1013 in
scientific notation!)
Questions about permutations involve selecting a subset of r letters from a set of n letters
and then arranging them in a row. Suppose we don’t care about how they are arranged.
That is, suppose we only want to know how many ways we can select a subset of r letters
from a set of n letters. The difference is this:

4! 4!
From a set of 4 letters a, b, c, d there are P(4, 2) = = = 4x3 = 12 ways to
(4  2)! 2!
arrange a subset of two of the letters in a row. Here are the ways:
ab ca
ac cb
ad cd
ba da
bc db
bd dc
but if we don’t care about the order in which the letters are arranged, then some of these
become the same; ab is the same as ba, cd is the same as dc, etc. In fact there are twice
as many permutations with 2 letters as there are subsets with two elements.

The same would be the case if we tried to count the number of 3-element subsets of a set
of 7 elements. We can use our formula for P(7, 3) to tell us how many ways there are of
arranging a subset of 3 elements from a set of 7 (call them a, b, c, d, e, f, g) but if we
don’t care about the order then some of those arrangements would be the same; for
instance, all of the following would be the same: abc, acb, bac, bca, cab, cba. For any
choice of three letters, all of the ways of arranging the three letters would be the same.
Since there are 3! (or 6) ways to arrange three letters we would have 3! times as many
permutations with 3 letters as there are subsets with 3 elements.

Let’s use the notation C(n, r) to stand for the number of subsets having r elements that
there are in a set of n elements. In combinatorics, a subset of a larger set is called a
combination. So C(n, r) is the number of r-element combinations taken from n elements.

What we’ve seen above is that P(n, r) is usually bigger than C(n, r) by r! times. In
symbols,
P(n, r) = r! x C(n, r)
Dividing both sides of this equation by r! we get a formula for C(n, r):
1
C(n, r) = P(n, r) x
r!
Now, remembering our formula for P(n, r) we can write this as
n! 1
C(n, r) = x
(n  r )! r!
Remembering how to multiply fractions, we can simplify this to
n!
C(n, r) =
(n  r )! r!
And we have the following:
FACT The number of ways to select a subset of r elements from a set of n elements is
n!
C(n, r) = .
(n  r )! r!
In other words, the number of ways to choose a combination of r things from a set of n
things is given by the formula at the right.

This formula for combinations helps us answer many questions about the real world!

Question If a pizza shop has 8 ingredients and you want to choose 3 of them to go on
your pizza, how many ways to do that are there?

Answer You are selecting a subset of 3 elements from a set of 8 elements, so the
formula gives
8!
C(8, 3) = .
(8  3)!3!
If you actually want to calculate out this last number, you can simplify by cancellation:
8! 8 x7 x 6 x5 x 4 x3x 2 x1
= = 8x7 = 56.
(8  3)!3! (5 x 4 x3 x 2 x1) x6

Question How many ways can you form a committee of 5 people from a group of 20
people?

Answer You are selecting 5 things from 20 things, so there are


20!
C(20, 5) =
(20  5)!5!
ways to do that. Calculating the actual number could be boring without a program to do
it for you! The answer turns out to be 15, 504.

Question If a security system requires that you simultaneously push 3 keys on a keypad
that has 10 keys, how many ways to do that are there?

Answer This is just


10!
C(10, 3) =
(10  3)!3!
which turns out to be only 120 ways.

It’s worth noting that the use of factorials can lead to some very large numbers. We have
3! = 6
5! = 120
7! = 5040
10! = 3,628,800
15! = 1,307,674,368,000
25! = about 1.551121 x 1025 in scientific notation.
These numbers get very big very fast!

You might also like