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

Combinatorics Sum and Product Rules

Problem: How to count without counting. Example 1: In New Hampshire, license plates consisted
• How do you figure out how many things there are with of two letters followed by 3 digits. How many possible
a certain property without actually enumerating all of license plates are there?
them. Answer: 26 choices for the first letter, 26 for the second,
Sometimes this requires a lot of cleverness and deep math- 10 choices for the first number, the second number, and
ematical insights. the third number:

But there are some standard techniques. 262 × 103 = 676, 000

• That’s what we’ll be studying. Example 2: A traveling salesman wants to do a tour of


all 50 state capitals. How many ways can he do this?
Answer: 50 choices for the first place to visit, 49 for the
second, . . . : 50! altogether.
Chapter 4 gives general techniques for solving counting
problems like this. Two of the most important are:

1 2

The Sum Rule: If there are n(A) ways to do A and, Some Subtler Examples
distinct from them, n(B) ways to do B, then the number
of ways to do A or B is n(A) + n(B).
Example 3: If there are n Senators on a committee, in
• This rule generalizes: there are n(A) + n(B) + n(C) how many ways can a subcommittee be formed?
ways to do A or B or C
Two approaches:
• In Section 4.8, we’ll see what happens if the ways of
doing A and B aren’t distinct. 1. Let N1 be the number of subcommittees with 1 sen-
ator (n), N2 the number of subcommittees with 2
senator (n(n − 1)/2), . . .
The Product Rule: If there are n(A) ways to do A According to the sum rule:
and n(B) ways to do B, then the number of ways to do
A and B is n(A) × n(B). This is true if the number of N = N1 + N2 + · · · + N n
ways of doing A and B are independent; the number of n!
choices for doing B is the same regardless of which choice • It turns out that Nk = k!(n−k)! (n choose k); this
you made for A. is discussed in Section 4.4
• A subtlety: What about N0? Do we allow sub-
• Again, this generalizes. There are n(A)×n(B)×n(C)
committees of size 0? How about size n?
ways to do A and B and C
◦ The problem is somewhat ambiguous.
If we allow subcommittees of size 0 and n, then
there are 2n subcommittees altogether.
◦ This is the same as the number of subsets of the
set of n Senators: there is a 1-1 correspondence
between subsets and subcommittees.
2. Simpler method: Use the product rule!
3 4
• Each senator is either in the subcommittee or out How many ways can the full committee be split into two
of it: 2 possibilities for each senator: sides on an issue?
◦ 2 × 2 × · · · × 2 = 2n choices altogether This question is also ambiguous.
General moral: In many combinatorial problems, there’s • If we care about which way each Senator voted, then
more than one way to analyze the problem. the answer is again 2n: Each subcommittee defines
a split + vote (those in the subcommittee vote Yes,
those out vote No); and each split + vote defines de-
fines a subcommittee.
• If we don’t care about which way each Senator voted,
the answer is 2n/2 = 2n−1.
◦ This is an instance of the Division Rule.

5 6

Coping with Ambiguity More Examples

If you think a problem is ambiguous: Example 4: How many legal configurations are there
in Towers of Hanoi with n rings?
1. Explain why
Answer: The product rule again: Each ring gets to
2. Choose one way of resolving the ambiguity “vote” for which pole it’s on.
3. Solve the problem according to your interpretation • Once you’ve decided which rings are on each pole,
• Make sure that your interpretation doesn’t render their order is determined.
the problem totally trivial • The total number of configurations is 3n
Example 5: How many distinguishable ways can the
letters of “computer” be arranged? How about “dis-
crete”?
For computer, it’s 8!:
• 8 choices for the first letter, for the second, . . .
Is it 8! for discrete? Not quite.
• There are two e’s
Suppose we called them e1, e2:
• There are two “versions” of each arrangement, de-
pending on which e comes first: discre1te2 is the same
as discre2te1.
• Thus, the right answer is 8!/2!
7 8
Division Rule: If there is a k-to-1 correspondence be- Permutations
tween of objects of type A with objects of type B, and
there are n(A) objects of type A, then there are n(A)/k
objects of type B. A permutation of n things taken r at a time, written
A k-to-1 correspondence is an onto mapping in which P (n, r), is an arrangement in a row of r things, taken
every B object is the image of exactly k A objects. from a set of n distinct things. Order matters.
Example 6: How many permutations are there of 5
things taken 3 at a time?
Answer: 5 choices for the first thing, 4 for the second,
3 for the third: 5 × 4 × 3 = 60.
• If the 5 things are a, b, c, d, e, some possible permuta-
tions are:
abc abd abe acb acd ace
adb adc ade aeb aec aed
...

In general
n!
P (n, r) = = n(n − 1) · · · (n − r + 1)
(n − r)!

9 10

Combinations More Examples

A combination of n things taken r at a time, written Example 8: How many full houses are there in poker?
C(n, r) or nr (“n choose r”) is any subset of r things
 

• A full house has 5 cards, 3 of one kind and 2 of an-


from n things. Order makes no difference. other.
Example 7: How many ways are there of choosing 3 • E.g.: 3 5’s and 2 K’s.
things from 5?
Answer: If order mattered, then it would be 5 × 4 × 3. Answer: You need to find a systematic way of counting:
Since order doesn’t matter, • Choose the denomination for which you have three of
abc, acb, bac, bca, cab, cba a kind: 13 choices.

are all the same. • Choose the three: C(4, 3) = 4 choices

• For way of choosing three elements, there are 3! = 6 • Choose the denomination for which you have two of
ways of ordering them. a kind: 12 choices

Therefore, the right answer is (5 × 4 × 3)/3! = 10: • Choose the two: C(4, 2) = 6 choices.

abc abd abe acd ace Altogether, there are:


ade bcd bce bde cde 13 × 4 × 12 × 6 = 3744 choices
In general
n!
C(n, r) = = n(n − 1) · · · (n − r + 1)/r!
(n − r)!r!

11 12
0! More Questions

It’s useful to define 0! = 1. Q: How many ways are there of choosing k things from
{1, . . . , n} if 1 and 2 can’t both be chosen? (Suppose
Why?
n, k ≥ 2.)
1. Then we can inductively define
A: First find all the ways of choosing k things from n—
(n + 1)! = (n + 1)n!, C(n, k). Then subtract the number of those ways in
and this definition works even taking 0 as the base which both 1 and 2 are chosen:
case instead of 1. • This amounts to choosing k−2 things from {3, . . . , n}:
2. A better reason: Things work out right for P (n, 0) C(n − 2, k − 2).
and C(n, 0)! Thus, the answer is
How many permutations of n things from n are there? C(n, k) − C(n − 2, k − 2)
n! n!
P (n, n) = = = n! Q: What if order matters?
(n − n)! 0!
A: Have to compute how many ways there are of picking
How many ways are there of choosing n out of n? k things, two of which are 1 and 2.
0 out of n?
  P (n, k) − k(k − 1)P (n − 2, k − 2)
n n!
 = =1




n 
n!0!
 
n n!
 = =1




0  0!n!

13 14

Q: How many ways are there to distribute four distinct Combinatorial Identities
balls evenly between two distinct boxes (two balls go in
each box)?
A: All you need to decide is which balls go in the first There all lots of identities that you can form using C(n, k).
box. They seem mysterious at first, but there’s usually a good
C(4, 2) = 6 reason for them.
Theorem 1: If 0 ≤ k ≤ n, then
Q: What if the boxes are indistinguishable?
C(n, k) = C(n, n − k).
A: C(4, 2)/2 = 3.
Proof:
n! n!
C(n, k) = = = C(n, n−k)
k!(n − k)! (n − k)!(n − (n − k))!

Q: Why should choosing k things out of n be the same


as choosing n − k things out of n?
A: There’s a 1-1 correspondence. For every way of choos-
ing k things out of n, look at the things not chosen: that’s
a way of choosing n − k things out of n.
This is a better way of thinking about Theorem 1 than
the combinatorial proof.

15 16
Theorem 2: If 0 < k < n then
     
n n − 1 n − 1
 =   + 


 

k   k  k − 1

Proof 1: (Combinatorial) Suppose we want to choose k


objects out of {1, . . . , n}. Either we choose the last one
(n) or we don’t.
1. How many ways are there of choosing k without choos-
ing the last one? C(n − 1, k).
2. How many ways are there of choosing k including n?
This means choosing k − 1 out of {1, . . . , n − 1}:
C(n − 1, k − 1).

Proof 2: Algebraic . . .

Note: If we define C(n, k) = 0 for k > n and k < 0,


Theorems 1 and 2 still hold.

17

You might also like