Counting: March 9, 2017

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

Counting

March 9, 2017

1 Counting Principle

Let X, Y be finite sets. If X, Y are disjoint, then


|X Y | = |X| + |Y |.
For two tasks T1 and T2 to be performed in sequence, if the task T1 can
be performed in m ways, and for each of these m ways the task T2 can be
performed in n ways, then the task sequence T1T2 can be performed in mn
ways. Using set notation, let X be the set of ways to perform the task T1 and
Y the set of ways to perform the task T2, then the product
X Y = {(x, y) | x X, y Y }
is the set of ways to perform the task sequence T1T2, and
|X Y | = |X||Y |.
Example 1.1. Suppose a lady has three hats, seven shirts, five skirts, and
four pairs of shoes. Assume all hats, shirts, skirts, and shoes are distinct. In
how many ways can the lady dress herself by wearing one hat, one shirt, one
skirt, and one pair of shoes?
answer = 3 7 5 4 = 420.
Example 1.2. Math courses Calculus, Linear Algebra, and Discrete Math-
ematics are taught by twenty, fifteen, and ten different instructors respectively
in Mega University. In how many ways can a student take two of the three
courses by selecting instructors?
Answer = 20 15 + 20 10 + 15 10 = 650.
Let X and Y be finite sets. Let f : X Y be a surjective function. If the
inverse image
f 1 (y) = {x X | f (x) = y}
has equal k elements for each y Y , then
|X|
|X| = | yY f 1 (y)| = yY |f 1 (y)| = k|Y | or |Y | = .
k

2 Permutations

Let A be a set of n objects. An arrangement of r elements from A in linear


order is called an r-permutation of n objects. Let P (A, r) denote the set of
all r-permutations of A. The number of r-permutations of n objects is denoted
by
Prn = |P (A, r)|.
In the process of producing an r-permutation of n objects, the 1st element
can be selected in n choices, the 2nd in n 1 choices, the 3rd in n 2 choices,
and so on. Thus
Prn = n(n 1) (n r + 1).
In particular, when r = n, an n-permutation of n objects is simply called a
permutation of n objects. The number of permutations of n objects is
n! = n(n 1)(n 2) 3 2 1,
where n! is read n factorial.

Example 2.1. How many possible seating plans can be made for four people
to be seated at a round table?
Solution. Let A = {a, b, c, d} be the set of four persons. Let X be the set of
all permutations of A, and Y the set of all round permutations of A.
We define a map f : X Y as follows: for each permutation x1x2x3x4,
f (x1x2x3x4) is the round permutation by joining the front side of x1 to the end
side of x4, and x1x2x3x4x1 forms a clockwise direction of f (x1x2x3x4).
Clearly, f is onto. This is because for each round permutation, we may
separate any two neighbors and stretch them into a linear permutation. There
are exactly 4 places to separate a round permutation into a linear permutation.
For instance, the four cyclic permutations
abcd, bcda, cdab, dabc
are sent to the same round permutation abcda in clockwise direction. We
then have
|X| = 4|Y |.
Thus
|X| 4!
|Y | = = = 3! = 6.
4 4

Proposition 2.1. The number of round permutations of n distinct objects


is
n!
= (n 1)!.
n
Corollary 2.2. The number of necklaces with n ( 3) distinct beads is
(n 1)!
.
2
Note that elements of a set are always distinct. When considering indistin-
guishable elements, we need the concept of multisets. By a multiset we mean
a collection of objects such that some of them may be identically same, called
indistinguishable. For instance,
{a, b, b, c, c, c, d, e, e}
is a multiset of 9 objects; it is not a set. The following
{2, 2, 3, 4, 4, 4, 4, 5, 5, 5}
is a multiset of 10 objects; and it is not a set.
Let A be a multiset of n objects of k distinguishable types. If there are ni
indistinguishable objects for the ith type, i = 1, 2, . . . , k, we call A a multiset
of type (n1, n2, . . . , nk ).
Example 2.2. In how many ways can 6 color balls of same size, of which 2
are white, 3 are black, and 1 is red, be arranged in linear order?
Solution. We denote 6 balls by letters w, w, b, b, b, r. To make the balls distin-
guishable, we label the balls of the same color with numbers. Then we have 6
distinct balls
w1, w2, b1, b2, b3, r1.
Let X be the set of permutations of the set {w1, w2, b1, b2, b3, r1}, and Y the set
of permutations of the multiset {w, w, b, b, b, r}. Let f : X Y be the map
such that each permutation of {w1, w2 , b1, b2, b3, r1 } is sent to a permutation of
{w, w, b, b, b, r} by merely erasing the labels of balls in the permutation. For
instance,

b w b b
1 1 2 3 1 2 r w



b 1 w1 b 3 b 2 r1 w2






b 2 w1 b 1 b 3 r1 w2






b w b b
2 1 3 1 1 2 r w






b 3 w1 b 1 b 2 r1 w2



b3w1 b2b1r1w2 f
12 = 2!3!1! 7 bwbbrw.

b1w2 b2b3r1w1



b 1 w2 b 3 b 2 r1 w1








b 2 w2 b 1 b 3 r1 w1





b2w2 b3b1r1w1




b 3 w2 b 1 b 2 r1 w1




b3w2 b2b1r1w1
Clearly, f is onto. For each permutation of the multiset {w, w, b, b, b, r}, the
inverse image f 1 () consists of 2!3!1! permutations of the set {w1, w2 , b1, b2, b3, r1 }.
Thus
|X| = 2!3!1!|Y |.
Therefore
|X| 6!
|Y | = = = 60.
2!3!1! 2!3!1!
Theorem 2.3. The number of permutations of n objects of type (n1, . . . , nk ),
where n = n1 + + nk , is given by
n!
.
n1!n2! nk !
Example 2.3. How many ways can five same calculus books, three same
physics books, and two same chemistry books be arranged in a bookshelf?
10!
Answer = = 2520.
5!3!2!
Corollary 2.4. The number of sequences of 0 and 1 of length n having
exactly r ones and (n r) zeros is given by
n!
.
r!(n r)!
Example 2.4. Counting the number of nondecreasing lattice paths from the
origin (0,0) to the point (6,4).
Solution. Each such lattice path can be viewed as a walk by moving 1 unit
length to the right or up. Let us denote the move of 1 unit to the right by R,
and the move of 1 unit up by U . Then each such lattice path can be viewed
as a sequence of R and U of length 10 having exactly 6 Rs and 4 U s. For
instance,
RRURRRUURU, URRRUURRUR, RUURRUURRR.
Thus
10!
answer = = 210.
6!4!

Proposition 2.5. The number of nondecreasing lattice paths from (0, 0)


to (a, b) with a, b N, is given by
(a + b)!
.
a!b!
Thinking Problem. Find a formula for the number of round permutations
of n objects of type (n1, n2, . . . , nk ). (Hint: Applying the Mobius inversion
formula and the Euler function; see Problem set. Not required.)
3 Combination

A combination is a collection of objects (order is immaterial) from a given


source of objects. An r-combination of n objects is a collection of r objects
from a source of n distinct objects, i.e., an r-subset of an n-set. We denote by
Pr (A) or Ar the set of all r-subsets of A. The number of r-combinations n
objects is denoted by
n  
A
:= |Pr (A)| = # ,
r r

read n choose r. Other common notations for nr are C(n, r), nCr, Cnk , Ckn.

Example 3.1. Find the number of 3-subsets of a 5-set


A = {a, b, c, d, e}
Solution. First Method: Let X be the set of permutations of A, and Y the
set of 3-subsets of A. Consider the map f : X Y , defined by
f (x1x2x3x4x5) = {x1, x2, x3}, x1x2x3x4x5 X.
Clearly, f is onto. For each S Y , i.e., a 3-subset S A, there are 3!2!
permutations of A such that f () = S. For instance, for S = {a, c, e}, we
have

acebd




aecbd





caebd





ceabd







eacbd



ecabd f
12 = 3!2! 7 {a, c, e}.

acedb




aecdb







caedb





ceadb





eacdb



ecadb
Thus |X| = 3!2!|Y |. Therefore,
 
5 |X| 5!
= |Y | = = = 10.
3 3!2! 3!2!
Second Method: Let X be the set of 3-permutations of A and Y the set of
3-subsets of A. Let f : X Y be defined by
f (x1x2x3) = {x1, x2, x3}, x1x2x3 X.
Clearly, f is onto. The 3! permutations of {x1, x2, x3} are sent to {x1, x2, x3}.
Thus |X| = 3!|Y |. Therefore
|X| P35 5 4 3
|Y | = = = = 10.
3! 3! 3!
Theorem 3.1. The number of r-combinations of n objects is
n n! Prn
= = .
r r!(n r)! r!
Theorem 3.2. (Binomial Theorem and Expansion)
n  
n
X n k nk
(x + y) = x y .
k
k=0
Proof.
(x + y)n = (x + y)(x + y) (x + y)
| {z }
n
X
= u1u2 un (ui = x or y, 1 i n)
n  
X # of sequences of x & y of length
=
n with exact k xs & (n k) ys
k=0
n  
X n k nk
= x y .
k
k=0

Example 3.2. A department consisting of 30 faculty members. Find the
number of ways to form a UG committee, a PG committee, and a promotion
committee consisting of 5, 3, and 4 respectively. I how many ways can the three
committees be formed without any restriction?
Solution.    
30 30 30
answer = .
5 3 4

A collection of ordered k disjoint subsets of an n-set is called a combination


of n objects of type (n1, n2, . . . , nk ) if the k subsets have the cardinalities
n1, n2, . . . , nk and
n = n1 + n2 + + nk .
A combination of n objects of type (n1, n2, . . . , nk ) can be viewed as a placement
of n objects into k boxes so that the 1st box contains n1 objects, the 2nd box
contains n2 objects, . . ., and the kth box contains nk objects. We denote by
 
n
n1 , n2 , . . . , nk
the number of combinations of n objects of type (n1, n2, . . . , nk ), read n choose
n1, n2, dot dot dot, and nk .

Example 3.3. How many ways can six distinct objects be placed into three
distinct boxes so that the 1st, 2nd, and 3rd boxes contain 2, 3, and 1 objects
respectively?
Solution. Let A = {a, b, c, d, e, f } be the set of six objects. Let X be the
set of permutations of A, and Y the set of placements of elements of A into
three boxes so that the 1st, 2nd, and 3rd boxes receives 2, 3, and 1 elements,
respectively. There is a map f : X Y , defined by
f (x1x2x3x4x5x6) = {x1, x2}{x3, x4, x5}{x6},
where x1x2x3x4x5x6 is a permutation of A.
Clearly, f is onto. For each P Y , there are 2!3!1! permutations of A sent
to P . For instance, for P = {a, c}{b, d, f }{e},


acbdf e




acbf de





acdbf e





acdf be







acf bde



acf dbe f
2!3!1! 7 {a, c}{b, d, f }{e}

cabdf e




cabf de







cadbf e





cadf be





caf bde



caf dbe
Thus |X| = 2!3!1!|Y |. Therefore
 
|X| 6! 6
|Y | = = = = 60.
2!3!1! 2!3!1! 2, 3, 1
Theorem 3.3. The number of ways to place n distinct objects into k
distinct boxes, so that the 1st, 2nd, . . ., kth boxes contain n1, n2, . . . , nk
objects respectively, equals
 
n n!
= .
n1 , n2 , . . . , nk n1!n2! nk !
Remark. When considering
 placement of n objects into two boxes of type
(r, n r), we write nr instead of
 
n n!
= .
r, n r r!(n r)!
Theorem 3.4. (Multinomial Theorem and Expansion)
(x1 + + xk )n =
 
X n n
xn1 1 xk k .
n1 ++nk =n
n1 , . . . , nk
n1 0,n2 0,...,nk 0
Proof.
(x1 + + xk )n
= (x1 + + xk ) (x1 + + xk )
| {z }
n
X
= u1 un (ui = x1, . . . , xk , 1 i n)
X  # of sequences of x1, . . . , xk of 
=
length n with n1 x1s, . . ., nk xk s
X  n

n
= xn1 1 xk k .
n ++n =n
n1 , . . . , nk
1 k
n1 0,...,nk 0

4 Combination with Repetition

We consider combinations with repetition allowed. The number of r-combinations


of n objects with repetition allowed is denoted by
DnE
.
r
Example 4.1. In how many ways can seven objects be taken with repetition
allowed from set A = {a, b, c, d}?
Solution. Take seven objects from A with repetition allowed, say, a, a, b, b, b, c, d.
This forms a multiset {a, a, b, b, b, c, d} of seven objects. We insert 3 sticks |
to separate elements of 4 different types to obtain a sequence aa|bbb|c|d, then
convert the sequence into a sequence 0010001010 of 0 and 1 by changing letters
to 0s and sticks | to 1s. For instance,
{a, a, b, b, b, c, d} aa|bbb|c|d 0010001010
{a, a, a, b, b, b, b} aaa|bbbb|| 0001000011
{b, b, c, c, c, c, c} |bb|ccccc| 1001000001
{a, c, c, c, d, d, d} a||ccc|ddd 0110001000
Let X be the set of 7-multisets of A, and Y the set of sequences of 0s and 1s
of length 10 (=7+3) with exactly seven 0s and three 1s. The above converting
actually defines a function f : X Y . Clearly, f is one-to-one and onto. Thus
     
4 10 4+71
answer = = |X| = |Y | = = .
7 7 7
Theorem 4.1. The number of r-combinations of n objects with repetition
allowed is    
n n+r1
= .
r r
Example 4.2. Eight students plan to have dinner together in a restaurant
where the menu shows 20 varieties. Each student decides to order one dish and
plans to share with others. How many possible combinations of eight dishes
can be ordered?
     
20 20 + 8 1 27
Answer = = = .
8 8 8
Theorem 4.2. The number of nonnegative integer solutions for the equa-
tion
x1 + x2 + + xn = r
is given by    
n n+r1
= .
r r

Example 4.3. There are five types of color T-shirts on sale, black, blue, green,
orange, and white. John is going to buy ten T-shirts; he has to buy at least two
blues and two oranges, and at least one for all other colors. Find the number
of ways that John can select ten T-shirts.
Solution. We use 1, 2, 3, 4, 5 to denote black, blue, green, orange and white
respectively. Let xi be the number of T-shirts that John would select for the
ith color T-shirt. Then the problem is to find the number of integer solutions
for the equation
x1 + x2 + x3 + x4 + x5 = 10, (1)
where x1 1, x2 2, x3 1, x4 2, x5 1.
Let x1 = y1 + 1, x2 = y2 + 2, x3 = y3 + 1, x4 = y4 + 2, x5 = y5 + 1. Then
(1) becomes
y1 + y2 + y3 + y4 + y5 = 10 7 = 3
with yi 0, 1 i 5. Thus
     
5 5+31 7
answer = = = = 35.
3 3 3
Example 4.4. (a) In how many ways can a student order eight dumplings
from three different kinds? (Assume that there are enough supply of dumplings
of each kind.)
(b) In how many ways can a student eat five dumplings selected from the
three kinds for free under the condition that dumplings of the same kind should
be eaten consecutively one by one?
(c) The same question as (b) having 5 changed to n and 3 changed to m.

3 10

Solution. (a) 8 = 8 = 45.
(b) There are k3 ways to select k types of dumplings, 1 k 3.
For each selected k types of dumplings, to select 5 dumplings so that each
kind is selected, it can be done as follows: Select one from each kind first. Then
D 5 E k dumplings from the k types with repetition allowed. Thus there
select
k
are 5k such selections.
For each selected k types of dumplings and a selection of 5 dumplings from
the k types so that each kind is selected, there are exactly k! ways to eat the
dumplings. Thus
3   
X 3 k
answer = k! = 63.
k 5k
k=1
Pm m

k

(c) answer = k=1 k! k nk .

5 Combinatorial Proof

Using bijection to prove an identity is sometimes called a combinatorial


proof. Here are a few examples.
Example 5.1. The identity
     
n+1 n n
= +
r r1 r
gives the Yang Hui Triangle (or Pascal Triangle).
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Proof. Let a1, a2, . . . , an+1 be distinct elements. Consider the sets
An = {a1, a2, . . . , an},
An+1 = {a1, a2, . . . , an, an+1}.
The r-subsets of An+1 are divided into two types.
Type I: r-subsets of An ;
Type II: r-subsets of An+1 , but not subsets of An .

There are nr r-subsets of Type I. Each r-subset of Type II must contain the
element an+1; and each such r-subset can be obtained by taking an (r 1)-
n
subsets of An first then adding the element an+1 to it. Thus there are r1
r-subsets
 of Type II. Adding the number of r-subsets of two types, we have
n+1 n n
r = r + r1 .

Example 5.2.
   2  2  2
2n n n n
= + + +
n 0 1 n
Proof. Consider n-combinations of 2n distinct balls, of which n balls are white
and the other n balls are black. Each n-combination can be obtained by taking
k balls from the n white balls and (n k) balls from the n black balls, where
0 k n. We then have
  n   
2n X n n
=
n k nk
k=0
n   
X n n
=
k k
k=0
 2  2  2
n n n
= + + + .
0 1 n
In general,  
m+n X  m  n 
= .
k i+j=k
i j
i,j0

6 Relation to Probability

There are many problems about chances or possibilities, called probability in


mathematics. When we flip a HK dollar coin, we have two possible outcomes,
Number and Flower. If the coin is fair, the chance to have the outcome, Flower,
is 50%. When we roll a pair of dice we may have outcomes, a collection of pairs
of numbers from 1 to 6. The chance of the event of the outcomes that the sum
of the pair is even is one-half. For instance, we may be interested in finding the
probability of the event of the outcomes that the sum of the pair is 8.
Definition 6.1. A collection of outcomes in a probabilistic experiment is called
an event. If each outcome is equally likely to be happened, we define
P (A) = Probability of an event A
number of favorite outcomes
= . (2)
number of possible outcomes
Example 6.1. What is the probability of selecting seven distinct numbers
from 1, 2, . . . , 11 so that two are less than 5, one is equal to 5, and four are
larger than 5?
11

Solution. The number
 1 of possible
 outcomes equals 7 ; the number of favorite
4 6
outcomes equals 2 1 4 . Thus
4
 1 6
2 1
probability = 11
 4 .
7

Example 6.2. Find the probability that no two persons have the same birth-
day in a party of 40 people.
40
Solution. The number
 of possible outcomes is 365 . The number of favorite
outcomes is 365
40
40!. Then
365

40!
probability = 40 40 0.109.
365
Example 6.3. What is the probability of rolling a pair of dice so that the sum
of numbers on the top facets equals 8?
First Method: Since there is no order between the two dice, there are 21 possible
outcomes
{i, j}, 1 i j 6
and three favorite outcomes {2, 6}, {3, 5}, {4, 4}. So the the probability is
3 1
21
= 7
0.14286.
Second Method: One may color the two dice as black and white so that the
two dice are ordered. There are 36(= 6 6) possible outcomes and five favorite
outcomes
(2, 6), (3, 5), (4, 4), (5, 3), (6, 2).
5
The probability equals 36 0.13889.
Which method is correct and why?
Example 6.4. Find the probability of rolling four dice simultaneously so that
the sum of points equals 9.
Solution. The number of possible outcomes is 64. The number of favorite
outcomes is the number of positive integer solutions of the equation
x1 + x2 + x3 + x4 = 9,
which is equal to the number of nonnegative integer solutions of the equation
y1 + y2 + y3 + y4 = 5.
Thus
4
5 7 1
probability = = .
64 162 23

7 Inclusion-Exclusion Principle

Let U be a finite set. For two subsets A1 , A2 U , we have


|A1 A2| = |A1| + |A2| |A1 A2|.
Equivalently,
|A1 A2| = |U | |A1| |A2| + |A1 A2 |.
For three subsets A1 , A2, A3 U , we have
|A1 A2 A3 | = |A1| + |A2| + |A3|
|A1 A2| |A1 A3| |A2 A3|
+|A1 A2 A3|,
Equivalently,
|A1 A2 A3| = |U | |A1| |A2| |A3|
+|A1 A2| + |A1 A3| + |A2 A3|
|A1 A2 A3|.
These formulas and similar kinds for more subsets are called the Inclusion-
Exclusion Principle.
Example 7.1. The pin numbers of Hang Seng Bank card are 6-digit nonneg-
ative integers. How many possible pin numbers can be made so that a triple
444 doesnt appear?
Solution. Let U be the set of all possible pin numbers. Then |U | = 106. Let
A1 = set of pin numbers of the form 444xxx,
A2 = set of pin numbers of the form x444xx,
A3 = set of pin numbers of the form xx444x,
A4 = set of pin numbers of the form xxx444,
where x varies from 0 to 9. Then
|A1| = |A2| = |A3| = |A4| = 103;
|A1 A2| = |A2 A3 | = |A3 A4| = 102,
|A1 A3| = |A2 A4| = 10,
|A1 A4 | = 1;
|A1 A2 A3| = |A2 A3 A4| = 10,
|A1 A2 A4| = |A1 A3 A4 | = 1;
|A1 A2 A3 A4 | = 1.
Thus the number of pin numbers equals
106 4 103 + (3 102 + 2 10 + 1) (2 10 + 2) + 1 = 996310.
Example 7.2. Find the number of positive integer solutions for the linear
equation x1 + x2 + x3 = 8.
Solution. Let U be the set of all nonnegative integer solutions of the equation
x1 + x2 + x3 = 8. Let Ai U be subsets such that xi = 0, 1 i 3. Then
     
3 3+81 10
|U | = = = = 45;
8 8 8
|A1| = |A2| = |A3| = 9;
|A1 A2| = |A1 A3 | = |A2 A3| = 1;
|A1 A2 A3| = 0.
By the Inclusion-Exclusion Principle,
|A1 A2 A3| = |U | |A1| |A2| |A3|
+|A1 A2| + |A1 A3| + |A2 A3|
|A1 A2 A3|
= 45 3 9 + 3 1 0 = 21.
The fastest way to get the answer is to apply substitution xi = yi + 1,
1 i 3. Then the answer is the number of nonnegative integer solutions of
y1 + y2 + y3 = 5, namely,
     
3 3+51 7
= = = 21.
5 5 5
Theorem 7.1. Let U be a finite set and Ai U be subsets, 1 i n.
Then
|A1 A2 An | = |A1| + |A2 | + |An|
|A1 A2 | + |A1 A3| + + |A1 An |
+|A2 A3| + |A2 A4| + + |A2 An |

+ + |An1 An |
 (3)
+ |A1 A2 A3| + + |An2 An1 An|

+(1)n1|A1 A2 An |
Pn k1
P
= k=1(1) 1i1 <<ik n Ai1 Aik .

Equivalently,
P P
|A1 A2 An| = |U | i |Ai | + i<j |Ai Aj |
P
i<j<k |Ai Aj Ak |
(4)
+ + (1)n|A1 A2 An|
Pn k
P
= |U | + k=1(1) 1i1 <<ik n Ai1 Aik .

Proof. For each element x U , we show that x contributes the same count to
both sides of (4).
Case I: x 6 A1 A2 An.
The element x is counted once on the left of (4) in
A1 A2 An = A1 A2 An;
and is counted once in U and 0 times in all subsets
Ai1 Ai2 Aik , where i1 < i2 < < ik .
Thus x is counted once on both sides left and right sides of (4).
Case II: x A1 A2 An .
We assume that x belongs to exactly r subsets of
A1, A2, . . . , An, say, At1 , At2 , . . . , Atr .
r
 r r r r

Then x is counted 0 , 1 , 2 , 3 , . . ., r times in
X X X
U, |Ati |, |Ati Atj |, |Ati Atj Atk |,
i i<j i<j<k

..., |At1 At2 Atr |, respectively.


Consequently, the contribution of x on the right side of (4) is
r  r  r  r   
r r
+ + + (1)
0 1 2 3 r
 r
= 1 + (1) = 0.
Therefore x is counted zero times on both sides of (4).
Remark. The subsets Ai U are usually given by conditions (or properties)
ci on the elements of U , 1 i n. Let
N = |U |;
N = # of objects satisfying none
of the conditions c1, . . . , cn ;
N (ci1 ci2 cik ) = # of objects satisfying
conditions ci1 , ci2 , , cik ,
1 i1 < i2 < < ik n.
Then the Inclusion-Exclusion Principle can be stated as
 
N = N N (c1 ) + N (c2 ) + + N (cn )

+ N (c1c2 ) + N (c1c3 ) + + N (c1 cn)
+N (c2 c3) + N (c2 c4) + + N (c2 cn )

+ + N (cn1 cn )
 
+ N (c1 c2c3) + + N (cn2 cn1 cn )
+ + (1)nN (c1c2 cn ). (5)
Let
X
Nk = |Ai1 Ai2 Aik |.
i1 <i2 <<ik

Then the Inclusion-Exclusion Formula can be stated as


|A1 A2 An| = N0 N1 + N2 N3 + + (1)nNn . (6)
Example 7.3. Find the number of possible Hong Kong telephone numbers
having no 14?
Solution. Let U be the set of Hong Kong telephone numbers. Obviously,
|U | = 108. Let
Ai = set of HK phone numbers whose ith digit
is 1 and (i + 1)th digit is 4, 1 i 7.
Then
7  
X 7
N1 = |Ai | = 106,
i=1
1
 
X 6
N2 = |Ai Aj | = 104,
1i<j7
2
 
X 5
N3 = |Ai Aj Ak | = 102,
3
1i<j<k7
 
X 4
N4 = |Ai Aj Ak Al | = 100.
4
1i<j<k<l7
Thus the answer is
7
 6
 5
 4

108 1 106 + 2 104 3 102 + 4 100 = 93149001.

8 Algebraic Proof of Inclusion-Exclusion Formula

Given a finite universal set U . Recall the characteristic function of subset


A of U is a function 1A : U R defined by

1 if x A
1A(x) =
0 if x 6 A.
For functions f : U R and g : U R, we define their addition and
subtraction as the following functions
f + g : U R, (f + g)(x) = f (x) + g(x),
f g : U R, (f g)(x) = f (x) g(x);
their multiplication as
f g : U R, f g(x) = f (x)g(x);
and the scalar multiplication for a constant real number a as
af : U R, (af )(x) = af (x).
The set of functions on a given set together with the addition and scalar
multiplication forms a vector space, called the vector space of functions.
Mover, the product of functions make the vector space of function into an
algebra. Note that the following so-called distributive law:
f (g + h) = f g + f h.
Proposition 8.1. Let A, B U and f : U R be a function. Then
(a) 1AB = 1A 1B ,
(b) 1A = 1U 1A, where A = U A,
(c) 1U f = f ,
(d) 1AB = 1A + 1B 1AB .
For each function f : U R, we define its weight as the number
X
w(f ) = f (x).
xU

Then for real numbers a, b R,


w(af + bg) = aw(f ) + bw(g).
Note that A1 An is the set of elements of U satisfying none of the
conditions c1 , . . . , cn . The set Ai1 Aik consists of the elements of U
satisfying the conditions ci1 , . . . , cik . On the one hand by Proposition 8.1, we
have
1A1 An = 1A1 1An
= (1U 1A1 ) (1U 1An )
X
= f1f2 fn (each fi is either 1U or 1Ai )
X
= |1U {z
1U} + 1|U {z
1U}(1Ai1 ) (1Aik )
n 1i1<<ik n nk
1kn
n
X X
= 1U + (1)k 1Ai1 1Aik
k=1 1i1 <<ik n
Xn X
k
= 1U + (1) 1Ai1 Aik .
k=1 1i1 <<ik n

On the other hand,


1A1 An = 1A1An = 1U 1A1 An .
Then n
X X
k1
1A1An = (1) 1Ai1 Aik .
k=1 1i1 <<ik n
Thus
|A1 An | = w(1A1An )
Xn X 
= (1)k1 w 1Ai1 Aik
k=1 1i1 <<ik n
Xn X
k1
= (1) |Ai1 Aik |.
k=1 1i1 <<ik n

9 Generalized Inclusion-Exclusion Formula

Theorem 9.1. Let U be a finite set, |U | = N . Let c1 , . . . , cn be some


properties about elements of U . Let
Em = {x U : x sarisfies exactly m properties of c1, . . . , cn .}
Then
     
m m+1 m+2
|Em | = Nm Nm+1 + Nm+2
0 1 2
 
n
+ (1)nm Nn . (7)
nm
Proof. It suffices to prove the following identity:
nm   X
X m + j
1Em = (1)j 1Ai1 Aim+j . (8)
j=0
j i <<i
1 m+j

The identity (7) follows from the (8) by applying the operator w to both sides.
For each x U , we count the contribution of x on both sides of (8). We
divide the situations into three cases.
Case I: x satisfies fewer than m conditions.
In this case the contributions of x on both sides are 0.
Case II: x satisfies exactly m conditions, say, ci1 , , cim .
The contribution of x on the left side is 1. The contribution of x on the right
side is also 1 because x is counted once in Nm and 0 times in all Nk for k > m.
Case III: x satisfies exactly r conditions, say, ci1 , , cir , and r > m.
The contribution of x to the left side is 0. On the right side, the contributions
of x to Nm , Nm+1, . . ., Nr are
     
r r r
, , ..., , 0, . . . , 0
m m+1 r
respectively; and the contributions of x to Nk with k > r are all 0. Thus the
contribution of x to the right side is
        
m r m+1 r r r
+ + (1)rm .
0 m 1 m+1 rm r
Now it is easy to see that
rm   
X m+j r
(1)j
j=0
j m+j
rm
X (m + j)! r!
= (1)j
j=0
j!m! (m + j)!(r m j)!
rm
X r! (r m)!
= (1)j
j=0
m!(r m)! i!(r m j)!
rm   
X r r m
= (1)j
i=0
m j
  rm  
r X r m
= (1)j
m j=0 j
 
r  rm
= (1) + 1 = 0.
m
Therefore the contributions of x on both sides are the same.

10 Pigeonhole Principle

Theorem 10.1. (Pigeonhole Principle) If n objects are placed into m boxes,


n > m, then there is at least one box containing more than one object.
The Pigeonhole Principle is a common Chinese saying: When pigeons are
put in pigeonholes, if pigeons are more than pigeonholes, there must be at least
two pigeons put in a same pigeonhole.

Example 10.1. Among any five integers between 1 and 8 inclusive, there are
at least two of them adding up to 9.
Solution. We can divide the set {1, 2, . . . , 8} into four disjoint subsets where
each has two elements adding up to 9:
{1, 8}, {2, 7}, {3, 6}, {4, 5}.
When selecting five numbers from these four subsets, at least two of the five
selected numbers must come from a same subset of the four subsets. Thus their
addition is 9.

Example 10.2. Show that in any group of two or more persons there are at
least two having the same number of friends. (It is assumed that if a person x
is a friend of a person y then y is also a friend of x).
Solution. Consider a group of n persons, n 2. The number of friends of a
person x should be an integer k, where 0 k n 1. If there is one person
x whose number of friends is n 1, then everyone is a friend of x. Thus 0
and n 1 can not be simultaneously the numbers of friends of some people in
the group. The Pigeonhole Principle tells us that there are at least two people
having the same number of friends.

Example 10.3. Show that if a1, a2, . . . , ak are integers (not necessarily dis-
tinct), then some of them can be added up to a multiple of k.
Solution. Consider the following k + 1 integers (not necessarily distinct):
0, a1, a1 + a2, a1 + a2 + a3, . . . , a1 + a2 + + ak . (9)
By the Division Algorithm, the remainders of any integer dividing by k can
only be 0, 1, 2, . . . , k 1. By the Pigeonhole Principle, there are at least two
integers in (9), say,
a1 + + ai and a1 + + aj
having the same remainder dividing by k. (The integer a1 + + ai could be
0, the very first integer in (9).) Thus the difference
(a1 + + aj ) (a1 + + ai ) = ai+1 + ai+2 + + aj
is a multiple of k.

Example 10.4. Given 10 distinct integers a1, a2, . . . , a10 such that 0 ai <
100. Is there any subset of {a1, . . . , a10} such that the sum of numbers of the
subset with sign is zero?
Solution. Consider all possible partial sums of the selected numbers a1, a2, . . . , a10.
The values of these sums should be between 0 and 1000. Note that the number
of subsets of 10 objects is 210 = 1024. By the Pigeonhole Principle, there are
at least two subsets A, B {a1, a2, . . . , a10} such that
X X
ai = aj .
ai A aj B

Move the numbers on the right side to the left; the numbers of the intersection
A B will be canceled. Thus, the sum of integers of AB with positive sign
in A B and negative sign in B A equals 0.
Theorem 10.2. If n objects are placed in m boxes, then one of the boxes
must contain at least mn objects.

Problem Set 3

1. A computer user name consists of three English letters followed by five


digits. How many different user names can be made?
Answer: 263 105.
2. A set lunch includes a soup, a main course, and a drink. Suppose a customer
can select from three kinds of soup, five main courses, and four kinds of
drink. How many varieties of set lunches can be possibly made?
Answer: 3 5 4.
3. (Not required) Find a procedure to determine the number of zeros at the
end of the integer n! written in base 10. Justify your procedure and make
examples for 12! and 26!.
4. How many different words can be made by rearranging the order of letters
in the word
 HONGKONG?

8
Answer: 2,2,2,1,1

5. A bookshelf is to be used to exhibit ten math books. There are eight kinds
of books on Calculus, six kinds of books on Linear Algebra, and five kinds
of books on Discrete Mathematics. Books of the same subject should be
displayed together.
(a) In how many ways can ten distinct books be exhibited so that there
are five Calculus books, three Linear Algebra books, and two Discrete
Mathematics books?
(b) In how many ways can ten books (not necessarily distinct) be exhibited
so that there are five Calculus books, three Linear Algebra books, and
two Discrete Mathematics books?
  
Solution: (a) 85 63 52 5!3!2! 3!.
(b) 85 63 52 3!.
6. There are n men and n women to form a circle (line), n 2. Assume that
all n men are indistinguishable and all n women are indistinguishable.
(a) How many possible patterns of circles (lines) could be formed so that
men and women alternate?
(b) How many possible patterns of lines can be formed so that each man is
next to at least one woman?
(c) How many possible patterns of circles can be formed so that each man
is next to at least one woman and each woman is next to at least one
man?
Solution. Case I: All n men are indistinguishable and all n women are
indistinguishable.
(a) Circle case: 1. Line case: 2.
(b) It is clear that no three or more men can be seated together.
Line Case. Let k denote the number of pairs of men in a seating plan,
where 0 k n2 . We may think of two men seated next to each other
as one big man. Then there are k big men and n 2k men. So there are
total n k Men (men and big men). The number of seating plans for these
n k Men on a line is the number words of zeros
 and ones with exactly k
ones and exactly n 2k zeros, which is nk k . Putting n k 1 women
between these n k Men, there are k + 1 remaining women. These k + 1
women can be arbitrarily distributed into n k + 1 locations among the
n k Men; there are h nk+1 n+1
k+1 i = ( k+1 ) ways to distribute the k + 1 women.
Thus the total number of required seating plans is
n/2 
X n k  n + 1 
.
k k+1
k=0

Circle case: Let k be the number of pairs of man seating together. Then
0 k n2 , and there are also k pairs of women seating together. There
are n 2k single man and k double-man; there are also n 2k single
women and k double women, seating alternately. Then the number of
seating patterns with k double-men and k double-women is
1 X  (n k)/d 
(d),
nk k/d
d| gcd(k,n)

where (d) is the number of integers in [1, d] coprime to d. The total


number of seating patterns is
n1
2
X 1 X  (n k)/d 
2+ (d).
nk k/d
k=1 d| gcd(k,n)

7. Four identical six-sided dice are tossed simultaneously and numbers showing
on the top faces are recorded as a multiset of four elements. How many
different multisets are possible?
Answer: h 64 i.
8. Find the number of non-decreasing coordinate paths from the origin (0, 0, 0)
to the lattice point (a, b, c).
 
a+b+c
Answer: a,b,c .
9. How many six-card hands can be dealt from a deck of 52 cards?
52 52
 52

Answer: P6 = 6 6! (a hand is ordered); 6 (a hand is unordered).
10. How many different eight-card hands with five red cards and three black
cards can be dealt from a deck of 52 cards?
26
 26  26
 26 
Answer: 5 3 8! (ordered); 5 3 (unordered).

11. Fortune draws are arranged to select six ping pang balls simultaneously
from a box in which 20 are orange and 30 are white. A draw is lucky if
it consists of three orange and three white balls. What is the chance of a
lucky draw?
( 203 )( 303 )
Answer: .
( 506 )
12. Determine the number of integer solutions for the equation
x1 + x2 + x3 + x4 38,
where
(a) xi 0, 1 i 4.
(b) x1 0, x2 2, x3 2, 3 x4 8.
Solution: (a) Note that there is a one-to-one correspondence between the
set of solutions for the inequality
x1 + x2 + x3 + x4 38
and the set of solutions for the equality
x1 + x2 + x3 + x4 + x5 = 38
with x5 0. Thus the number of solutions for the inequality is
   
5 5 + 38 1
= .
38 38
(b) Let x1 = y1, x2 = y2 + 2, x3 = y3 2, x4 = y4 + 3. Then the equation
becomes y1 + y2 + y3 + y4 35 with yi 0 for 1 i 4 and y4 5.
Solution: The number of solutions is the same as the number of solutions
of y1 + y2 + y3 + y4 + y5 = 35 with y4 5.
P
4 P5 38i 
Answer: 5i=0 35i = i=0 35i
13. Determine the number of nonnegative integer solutions to the pair of equa-
tions
x1 + x2 + x3 = 8, x1 + x2 + x3 + x4 + x5 + x6 = 18.
Solution: We need to count

3
the number of tuples (x1, . . . , x6) satisfying
3
both equations. Answer: 8 10 = 10
8
12
10
.
14. Show that there must be at least 90 ways to choose six numbers from 1 to
15 so that all the choices have the same sum.
Solution: (a) The six selected numbers are not necessarily distinct. Note
that
1| + {z | + {z
+ 1} = 6, 15 + 15} = 90.
6 6

15 20

There are 85 integers in [6, 90]. However, 6 = 6 = 38760. Then are at
least 38760/85 = 456 ways to choose six integers (not necessarily distinct)
whose sums are the same. (b) The six selected numbers are distinct. Note
that 1+2+ +6 = 21 and 10+11+  +15 = 75. There are 55 integers in
[21, 75]. However, there are 15 6
= 5005 ways to select six integers. Thus
on average there are 5005/55 = 91 selections have the same sum.
15. Show that if five points are selected in a square whose sides
have length 2,
then there are at leat two points whose distance is at most 2.
Answer: Dividing the square of length 2 into 4 squares of length 1. Then
at least two points
must be in one small square, and the distance is less
than or equal to 2.
16. Prove that if any 14 numbers (not necessarily distinct) from 1 to 25 are
chosen, then one of them is a multiple of another.
Solution: Dividing integers in [1, 25] into 13 pigeonholes
{1, 2, 4, 8, 16}, {3, 6, 12, 24}, {5, 10, 20}, {7, 14}, {9, 18},
{11, 22}, {13}, {15}, {17}, {19}, {21}, {23}, {25}.
17. Twenty disks labelled 1 through 20 are placed face down on a table. Disks
are selected (by a player) one at a time and turned over until 10 disks have
been chosen. If the labels of two disks add up to 21, the player loses. Is it
possible to win this game?
Answer: Yes. Dividing 20 integers 1, 2, . . . , 20 into pigeonholes
{1, 20}, {2, 19}, {3, 18}, {4, 17}, {5, 16},
{6, 15}, {7, 14}, {8, 13}, {9, 12}, {10, 11}.

The chance the player can win the game is 210/ 20 10
.
18. Show that it is impossible to arrange the numbers 1, 2, . . . , 10 in a circle so
that every triple of consecutively placed numbers has a sum less than 15.
Solution: Let the 10 numbers be arranged as a1, a2, . . . , a10 in a circle so a1
is next to a10. Then a1 + a2 + a3 14, a4 + a5 + a6 14, a7 + a8 + a9 14,
and a10 10. Thus a1 + a2 + + a10 3 14 + 10 = 52. However,
a1 + a2 + + a10 = 1 + 2 + + 10 = 55, a contradiction.
19. In how many ways to arrange the letters E, I, M , O, T , U , Y so that
Y OU , M E and IT would not occur?
Solution: Let U be the set of all arrangements of
E, I, M, O, T, U, Y . Let A, B, and C be the sets of arrangements with
Y OU , M E, and IT respectively. Then
|A B C| = |U | |A| |B| |C| +
|A B| + |A C| + |B C|
|A B C|
= 7! 5! 6! 6! + 4! + 4! + 5! 3!.
20. Six passengers have a trip by taking a van of six seats. Passengers randomly
select their seats. When the van stops for a break, every passenger left the
van.
(a) What is the chance that the seat of every passenger after a break is the
same as their seat before the break?
(b) What is the chance that exactly five passengers have the same seats
before and after a break?
(c) What is the probability that at least one passenger has the same seat
before and after a break?
Solution: (a) 1/6!; (b) 0; (c) We find the probability p that no one got
his/her original seat. Let U be the set of all possible seating plans. Let Ai
be the set of all possible seating plans that the ith person got his original
seat, 1 i 6. Then
X X
p = |U | |Ai| + |Ai Aj |
i i<j
     
6 6 6
= 6! 5! + 4! 3! +
1 2 3
     
6 6 6
2! 1! + .
4 5 6

21. (Note required) Let M be a multiset of type (n1, n2, . . . , nk ) such that
ni 1 for 1 i k. If the numbers n1, n2, . . . , nk are all coprime with
n = n1 + n2 + + nk , then the number of round permutations of M is
 
n
n1 ,n2 ,...,nk
.
n
The formula is actually valid when gcd(n1, . . . , nk ) = 1, but we didnt
define the gcd yet for more than two integers. Find a counterexample if the
conditions are not satisfied.
22. (Not required) Find the number of nondecreasing lattice paths from the
origin (0, 0) to a non-negative lattice point (a, b), allowing only horizontal,
vertical, and diagonal unit moves; that is, allowing moves
(x, y) (x + 1, y),
(x, y) (x, y + 1),
(x, y) (x + 1, y + 1).

Hint: For any such path with k diagonal moves (0 k min{a, b}), the
number of horizontal moves should be a k and the number of vertical
moves should be b k. Thus
min{a,b}  
X a+bk
answer: .
a k, b k, k
k=0

23. (Not required) Thinking problem. Find the number of nondecreasing


lattice paths from the origin (0, 0) to a nonnegative lattice point (a, b),
allowing arbitrary straight moves from one lattice point to another lattice
point so that no lattice points on the line between two lattice points; that
is, allowing all moves
(x, y) (x + k, y + h),
where k, h N, (h, k) 6= (0, 0), gcd(k, h) = 1.
(Answer: unknown)

You might also like