Sei sulla pagina 1di 20

MAT344

Professor S. Tanny

Enumerative Combinatorics . . . How do I love thee? Let me count


the ways! (E. B. Browning)
Count the number of elements in a (finite) set, or the number of ways of
arranging the elements of finite sets into definite patterns. For example:
(1) how many ways are there to climb a staircase with 12 stairs if you
take the stairs either 1 or 2 at a time? (2) how many ways are there
to arrange the numbers from 1 to 10 around a circle so that no two
consecutive numbers are adjacent?
Such questions have ancient roots

magic squares (China, 2200 BCE)


permutations (China, 1100 BCE)
n-permutations (Sefer Yetzirah, 200-500 CE)
(movement of heavenly bodies)
Pascal, Fermat (16-17th CE) (games of chance, or gambling)
1

MAT344

Professor S. Tanny

We begin with some puzzles and games.


A.

In the above, find the fewest number of moves required


to rearrange the balls from (a) to (b), where
only 1 ball at a time can be moved.

Note: Count the number of moves that are required in your solution.
Be sure to show why the task cannot be accomplished in fewer moves.

MAT344
B.

Professor S. Tanny

Tower of Hanoi: There are n rings on Tower 1, each of successively


smaller size. You are only allowed to move one ring at a time.
You can never put a larger ring on top of a smaller ring. You
are allowed to put rings on either of towers 2 or 3 temporarily. Find
the minimum number of moves that are required to transfer all the
n rings from the first tower to the second tower.

Note: Is it apparent that this can always be accomplished at all? Why?


A start at the solution: Let an be the required number. Think small!!
For n = 1, we have a1 = 1. For n = 2 we can first show that a2 3
by demonstrating a way to accomplish the task in 3 moves. Then we
observe that a2 > 2 since we need 2 moves to move the bottom ring.
It follows that a2 = 3.
What is the solution for general n?
3

MAT344

Professor S. Tanny

C. Game of SIM: In this game there are 6 dots in the plane and 2
players, Red and Blue. Each player alternately makes a move by joining
a pair of dots by a line in his (her) colour, either Red or Blue. The
winner is the first player to form a triangle in a single colour (note:
the sides of the triangle must originate at the 6 dots, and not at the
intersections of the interior lines drawn).
Is this a finite game? What is the maximum number of moves?
Would you rather go first or second?
Is there always a winner?
Is there a winning strategy for either player? If so, for which player?

Hint: To help you get the idea, think of another game between two
players that is finite and determine the answers to the above questions
for that game.
4

MAT344

Professor S. Tanny

Basic Counting Rules and Why They Work


We want to represent the letters of an alphabet with 2 digit binary
strings. How many different letters can we represent? (This is the
maximum size of the alphabet.)
 
22

01
00

10
11

Product Rule: If there are n1 ways to do a first thing, and n2 ways to


do a second (irrespective of the outcome for the first) then there are
n1 n2 ways to do both things.

MAT344

Professor S. Tanny

Example: How many different Ontario licence plates can be issued, if


each consists of 3 letters followed by 3 numbers?

26


26


26


10


10


10

Think about this variation of the above question: How many different
Ontario licence plates can be issued, if each consists of 3 letters followed
by 3 numbers, where the three letters and the three numbers can come
in any order?

MAT344

Professor S. Tanny

Heres a more formal mathematical approach to the Product Rule.


Suppose S is the set of solutions to some combinatorial problem. Suppose we can write S as a cross product of two sets, that is, in the form
S = S1 S2. Then card (S) = card (S1) card (S2), where card (S) is
the number of elements in S. More generally, if S = S1 S2 . . . Sn,
then card (S) =

n
Y

card (Si).

i=1

Exercise: Find the number of divisors of 21? Of 21,168?


(Hint: 21, 168 = 24 33 72).
Example: We have 16 different books: 5 in Spanish, 4 in French, and
7 in English. In how many ways can we choose three books, no two of
them in the same language?
Since no two books can be from the same category, we must choose
one book from each category. There are 5 ways to choose a Spanish
book, 4 ways to choose a French book, and 7 ways to choose an English
book. Using the product rule, we get 5 4 7 ways.
7

MAT344

Professor S. Tanny

Example: We have 16 different books: 5 in Spanish, 4 in French, and


7 in English. In how many ways can we choose a pair of books that are
not both in the same language?
There are 3 different possible pairs of books in different languages,
namely, S F , S E and F E, and our choice will involve exactly one
of these pairs. First we compute the number of ways we could draw a
pair of each type. There are 5 Spanish books and 4 French books, so
using the product rule there are 20 different choices for the S F pair.
Similarly we count the number of choices for the other two pairs. But
since we can choose only one of these pairs, we choose either S F (20
ways) or S E (35 ways) or F E (28 ways). So the total number of
ways is the sum of these. Thus:
S-F
S-E
F-E

20
35
28
83
8

MAT344

Professor S. Tanny

Sum Rule: If you can do one thing in n1 ways and a second thing in
n2 ways, there are n1 + n2 ways that you can do either first thing or
second thing, but not both.
Here is a more formal mathematical approach to the sum rule:
let S be the set of solutions to some mathematical problem. Suppose
we can write S = S1 S2, where S1 S2 = . Then card (S) = card
(S1)+ card (S2).
More generally, if we have S =

n
[

Si, and Si Sj = if i 6= j (that is,

i=1

the sets are pairwise disjoint), then card (S) =

n
P
i=1

card (Si).

Note: The collection {S1, S2, . . . , Sn} is called an n-partition of the set
S.
Exercise: Use mathematical induction to prove the general form of the
product rule and the sum rule.
9

MAT344

Professor S. Tanny

Example: How many 3 letter sequences (so order counts) using the
letters a, b, c, d, e, f are there of the following type:
a)
b)
c)
d)

allow repetition
no repetition
no repetition and must contain e
allow repetition and must contain e

a)
b)
c)
d)

63 (product rule)
6 5 4 (product rule)
60 = (5 4) + (5 4) + (5 4) (product and sum rules)
63 53 = 91 (What do 63 and 53 each count?)

Note: You can solve part d) by considering three separate cases,


i.e., sequences with 1e, 2e, or 3e. Try it!
10

MAT344

Professor S. Tanny

Exercise: Suppose two baseball teams A and B play a best of five


series; that is, the winner is the team to first win 3 games. Find the
number of different possible outcomes in which team A wins the series.
Represent the winner of a game by its letter. Then any outcome of the
series in which A wins consists of an arrangement of A0s and B 0s with
at least 3 A0s and at most 2 B 0s, and where A must be the last letter
in the sequence.
If the sequence has only 3 letters, then the sequence consists of 3 A0s,
so there is only 1 such sequence. If it has 4 letters, it ends in A and
there are 3 places to put the single B, so there are 3 sequences in all of
this type. Finally, if it has 5 letters, it must end in A and there are 2 B 0s
among the first 4 letters. Verify that there are 6 different possibilities.
Using the sum rule we conclude that there is a total of 10 sequences in
which A wins the series.
11

MAT344

Professor S. Tanny

Permutations
We now count the number of ways to arrange the elements of a set.
Recall that by definition a set contains distinct objects. For example,
the set S = {1, 2, 3, 4} is a set with 4 elements (cardinality 4).
Sometimes we also count arrangements of multisets. A multiset is a
collection of not necessarily distinct elements, so it may contain multiple
copies of the same element. For example, M = {13, 2, 35} denotes a
multiset M containing 3 copies of the element 1, a single element 2, and
5 copies of the element 3. An arrangement of a multiset is equivalent
to arranging a set but allowing some number of repetitions of one or
more of the elements.
Let S be a set with n elements. By the Product Rule there are n! =
n (n 1) . . . 3 2 1 ways to arrange the elements of S. Further, there
are n(n 1) (n r + 1) ways to create r-element sequences (that is,
arrangements of r of the elements of S) drawn from the n elements of
S.
12

MAT344

Professor S. Tanny

We introduce the following notation:


Set of the first n positive integers: [n] = {1, 2, , n}
Alternate way to write n!: nn
n!
Falling factorial: nr = n(n 1) (n r + 1) = (nr)!

Rising Factorial:

r
nr = n(n+1) (n+r1) = (n+r1)!
=
(n+r1)
(n1)!

What is the value of 00?


By convention, 00 0! = 1. Heres one reason why: by definition, for
any positive integer n, nn = n (n 1)n1. Take n = 1 : 11 = 1 =
1 00 00 = 1
13

MAT344

Professor S. Tanny

Counting the Number of Subsets of the Set [n]


For any nonnegative integer k, a k-subset of [n] is a subset of [n] with
k elements. If k = 0 then there is only 1 subset, namely, the null set .
How many k-subsets of [n] are there?
An example: suppose n = 4 and k = 2. We enumerate all the 2-element
subsets of [4]:
12
34

13
23

14
24

Thus, there are precisely 6 2-element subsets of [4].


How can we answer the question in general?
14

MAT344

Professor S. Tanny

Let x be the number of k-subsets of [n]. By what we showed earlier for


permutations, we know that each k-subset of [n] can be arranged in k!
different ways. Thus, xk! counts the number of ordered k-subsets of [n].
But any such ordered k-subset is, by definition, just a k-permutation,
and we know that there are nk k-permutations. Thus we conclude that
!
k
n
x k! = nk , so x = nk! . Another way of writing this expression is
,
k
which is called a binomial coefficient and read as n!choose k. Finally,
n
n!
from this it follows immediately by algebra that
= k!(nk)!
.
k
!

What is

3
? For n 0, what is
4

n
?
0

1
n0
n
= 0 = = 1,
0
0
1
!

n0
15

MAT344

Professor S. Tanny

Example: A box contains 7 distinct balls numbered 1 through 7. Three


balls (1,2,3) are blue, two (4,5) are red, and two (6,7) are green. Find
the number of selections of three balls which contain at least two blue
balls.
!

Solution 1: Choose the two blue balls in

3
2

= 3 ways. Choose the


!

remaining ball from the five remaining balls in

5
1

= 5 ways. By the

product rule, the answer is 3 5 = 15.

16

MAT344

Professor S. Tanny

Example: A box contains 7 distinct balls numbered 1 through 7. Three


balls (1,2,3) are blue, two (4,5) are red, and two (6,7) are green. Find
the number of selections of three balls which contain at least two blue
balls.
Solution 2: Each selection will be one of the following:
a)

3 blue balls - 1 way

b)

blue balls (1,2) plus one ball of another colour - 4 ways

c)

blue balls (1,3) plus one ball of another colour - 4 ways

d)

blue balls (2,3) plus one ball of another colour - 4 ways

Now add these up, using the sum rule, to get 13.
Which answer is correct, and why?

17

MAT344

Professor S. Tanny

The triangle formula is a very important combinatorial identity involving


binomial coefficients:
!

n+1
n
n
=
+
k
k
k1

We use a combinatorial argument to prove this identity. The strategy


is to show that both sides of the identity count the same thing in
different ways.
By definitions, the left hand side of the identity counts all of the ksubsets of the set [n + 1]. Now we show that the right hand side counts
these k-subsets too.

18

MAT344

Professor S. Tanny

Fix your eye on any specific element of [n + 1], say the element (n + 1).
For any k-subset of [n + 1], (n + 1) is either in or out of the k-subset.
But a k-subset of [n +!1] where (n + 1) is out
! is a k-subset of [n], and
n
n
we know there are
such k-subsets, so
counts all the k-subsets
k
k
of [n + 1] where (n + 1) is out.
Further, any k-subset of [n+1] where (n+1) is in must contain
! a unique
n
set of k 1 additional elements from [n]. There are
ways to
k1
!
n
choose these k 1 elements so
counts all k-subsets of [n + 1]
k1
where (n + 1) is in.
By the sum rule, the right hand side also counts all the k-subsets of
[n + 1].
19

MAT344

Professor S. Tanny

Here is an algebraic proof of the previous identity. This proof uses the
factorial definition of the binomial coefficient:
!

n
n
+
k
k1

n!
n!
+ (k1)!(nk+1)!
= k!(nk)!

h
i
n!
1+
1
nk+1
(k1)!(nk)! k

h
i
n+1
n!
(k1)!(nk)! k(nk+1)

(n+1)!
= k!(nk+1)!

n+1
k

Notice that this proof does not work for k = 0 or k = n + 1? Why? To


cover these cases you must do them separately.
As you can see, the algebraic proof is not nearly as elegant or illuminating
as the combinatorial proof. In this course we give combinatorial proofs
whenever we can.
20

Potrebbero piacerti anche