Administrative info
Review session Sunday 7/10 5pm in 310 Soda
MT1 policies
- 1 cheat sheet (8.5x11, double sided)
- no calculators
Old exams online; see email
Review
Last time, we started to learn how to count. We saw how to count by
enumerating all possibilities and by using tree diagrams.
More Counting
(2) Product rule
EX: If you have to do two projects for a class, the first chosen
from a list {P1, P2} and the second from a list {PA, PB,
PC}, how many different pairs of projects can you turn in?
ANS: Let S be the set of all pairs, S1 = {P1, P2}, S2 = {PA, PB,
PC}. Then
S = {(P1, PA), (P1, PB), (P1, PC), (P2, PA), (P2, PB),
(P2, PC)}
|S| = 6 = |S1| x |S2|
In general, the set of pairs where the first member is from a set
S1 and the second member is from a set S2 is called the Cartesian
product of S1 and S2 and is written as
S1 x S2 = {(a, b) : a in S1 and b in S2}
Then the cardinality of S1 x S2 is the product of the
cardinalities of S1 and S2, |S1 x S2| = |S1| x |S2|.
We could have enumerated S above using a decision tree.
projects
/ \
1st P1 P2
/ | \ / | \
2nd PA PB PC PA PB PC
What do you notice about this tree? The branching factor at each
level is the same for every node at a particular level: 2 for
the first level, 3 for the second. If this is the case, then the
number of leaves in the tree (i.e. elements in S) is the product
of the branching factors, 2 * 3 = 6.
More generally, for the Cartesian product of k sets, we have
|S1 x S2 x ... x Sk| = |S1| x |S2| x ... x |Sk|
Can you prove this using induction?
EX: How many two-digit numbers are there? (10 x 10 = 100)
EX: How many 10-digit phone numbers are there? (10^10)
(Assume any 10-digit number can be a phone number.)
EX: How many different license plates are there that consist of
a number, followed by 3 letters, followed by 3 numbers?
(10^4 * 26^3)
EX: How many ways can you shuffle a 52-card deck? (52!)
(3) Sum rule
EX: If you have to do one project for a class, chosen either
from a list {P1, P2} or from a list {PA, PB, PC}, how many
different projects can you turn in?
ANS: Let S be the set of projects, S1 = {P1, P2}, S2 = {PA, PB,
PC}. Clearly S = S1 ∪ S2 = {P1, P2, PA, PB, PC}. So we
get |S| = 5 = |S1| + |S2|.
Thus, if we have S = S1 ∪ S2 for any *disjoint* sets S1 and
S2, then |S| = |S1| + |S2|.
EX: How many 10-digit phone numbers are there with 0 or 1 as
the second digit?
ANS: Let S be the set of such phone numbers, S1 be the set of
phone numbers with 0 as the second digit, S2 be the set of
phone numbers with 1 as the second digit. Then
S = S1 ∪ S2, S1 and S2 disjoint
|S1| = 10^9 (product rule), |S2| = 10^9
|S| = |S1| + |S2| = 2 * 10^9
What if the subsets are not disjoint?
EX: If you have to do one project for a class, chosen either
from list {P1, P2, PA} or from list {PA, PB, PC}, how many
projects can you turn in?
ANS: Let S be set of possible projects, S1 = {P1, P2, PA},
S2 = {PA, PB, PC}. Then S = S1 ∪ S2 = {P1, P2, PA, PB,
PC}, and |S| = 5 != |S1| + |S2| = 6.
Why can't we add the sizes of the subsets in general? Because we
double count the items that are in their intersection, in this
case PA. To fix this, we can undo the double counting. Note that
S1 ∩ S2 = {PA}, and |S1 ∩ S2| = 1. So if we subtract off
the size of the intersection, we get the right answer.
|S| = |S1| + |S2| - |S1 ∩ S2|
This is called the inclusion/exclusion principle.
EX: How many 10-digit phone numbers have 7 as their first or
second digit?
ANS: 10^9 + 10^9 - 10^8
More examples
EX: I have a red die and a blue die. I roll them. How many
outcomes are there where they have different values?
ANS: product rule/tree: choose what red shows (6 choices), then
choose blue (5 choices)
ANS: complement: 36-|T|, where T = red+blue show same number
[Sometimes it's easier to count the complement of a set
rather than the set itself.]
EX: How many m-digit numbers are there base n? (n^m)
EX: How many functions S->T, if |S|=m, |T|=n? (n^m)
EX: How many functions that are one-to-one, if n > m?
ANS: n * (n-1) * ... * (n-m+1) = n!/(n-m)!
(4) Isomorphism principle
EX: If I roll two dice, a red one and a blue one, how many
outcomes are there in which the value of the red die is
larger than that of the blue one?
ANS: Let R be the set of outcomes where the red one is bigger, B
be the set of outcomes were the blue one is bigger.
We already saw that |R| + |B| = 30.
By symmetry, |R| = |B|, so |R| = 15.
If two sets S1 and S2 can be put into a bijective
correspondence, then |S1| = |S2|.
EX: How many subsets of are there of {1, 2, 3, 4, 5}?
ANS: Represent a subset as a 5 bit string. Bit i is 1 if element
i is in the subset, 0 if not. (Examples: {1, 4, 5} = 10011,
{2, 3} = 01100.) We now have a bijective correspondence
between the set of subsets of {1, 3, 4, 5, 5} and the set
of 5-bit strings. The latter has size 2^5, so the former
does as well.
EX: A farmer was showing a mathematician around his fields.
Frustrated by his endless demonstrations of cerebral
aptitude, the farmer decided to teach him a lesson. He took
the mathematician to a field that was packed with hundreds
of grazing sheep, all of them milling about and moving
around. "If you can guess the exact number of sheep in this
field," challenged the farmer, "I'll give you all of them!"
The mathematician looked thoughtful for a moment, and his
eyes darted back and forth rapidly. Presently he announced,
"Two hundred and fourteen." The farmer gaped, too stunned to
calculate his loss yet, "How on Earth did you do that?
There's no way you could have counted all those sheep that
fast!" "You are absolutely right," the mathematician agreed.
"I counted all the legs, and then divided by four."
If set S1 has a k-to-1 correspondence to set S2, then |S2| =
|S1|/k.
(5) Pigeonhole principle
EX: Are there two non-bald residents of New York City with
exactly the same number of hairs on their heads?
ANS: There are at most 10^6 hairs on anyone's head. There are
more than 10^6 non-bald New Yorkers, so there must be a
pair that have the same number of hairs.
If k+1 (or more) pigeons are placed in k holes, then there must
be some box that has at least two pigeons.
Proof by contradiction:
Suppose every one of the k+1 pigeons is in a different hole Then
there must be at least k+1 holes. Since there are only k holes,
this is a contradiction.
(6) Permutations
EX: How many 10-digit phone numbers are there in which no number
appears twice?
ANS: product rule: 10!
This is just the number of orderings on the set {0, 1, ..., 9},
i.e. a permutation of the set. For any set S of n elements, the
number of permutations is always n!. (Proof by using product
rule as above.)
EX: How many anagrams are there of the word "primes"? (6!)
EX: How many 3-digit area codes have no repeated number?
ANS: product rule: 10 * 9 * 8 = 10!/7!
ANS: There are 10! choices for the full 10-digit phone number.
Each area code has 7! phone numbers (7 remaining digits to
choose). So there is a 7!-to-one correspondence between
phone numbers and area codes, resulting in 10!/7! area
codes.
An r-permutation of a set S is an ordered list of r elements
from S. An area code with no repeated number is a 3-permutation
of the set S = {0, ..., 9}. For any set S with n elements,
there are n!/(n-r)! r-permutations. (Proof by product rule.)
EX: Of the 30 different baseball teams, how many different sets
of World Series winners and losers are there?
ANS: This is a 2-permutation of the 30 teams, so there are
30!/28! = 30*29 (compare to product rule).
EX: How many anagrams are there of the word "berkeley"?
ANS: This is a bit harder. Let's start by assuming that the e's
are distinguishable, so we count the number of permutations
of the word "bérkêlëy". There are 8!. Now for any
ordering of the e's when they are distinguishable, there
are 3! orderings where they aren't:
bérkêlëy, bêrkélëy, bërkélêy,
bérkëlêy, bêrkëléy, bërkêléy
So there is a 3!-to-one correspondence between anagrams of
Berkeley with distinguishable e's to anagrams with
identical e's. So the number of the latter is 8!/3!.