Counting - Meng, Guan (WS, 2002)
Counting - Meng, Guan (WS, 2002)
NTING
Tay Eng Guan
World Scientific
COUNTING
This page is intentionally left blank
COUNTING
V f e World Scientific
WM New Jersey • London *Sini
• Singapore • Hong Kong
Published by
World Scientific Publishing Co. Pte. Ltd.
P O Box 128, Farrer Road, Singapore 912805
USA office: Suite IB, 1060 Main Street, River Edge, NJ 07661
UK office: 57 Shelton Street, Covent Garden, London WC2H 9HE
The authors and publisher would like to thank the following organizations for their permission to
reproduce the selected problems in this book:
COUNTING
Copyright © 2002 by World Scientific Publishing Co. Pte. Ltd.
All rights reserved. This book, or parts thereof, may not be reproduced in any form or by any means,
electronic ormechanical, including photocopying, recording or any information storage and retrieval
system now known or to be invented, without written permission from the Publisher.
For photocopying of material in this volume, please pay a copying fee through the Copyright
Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, USA. In this case permission to
photocopy is not required from the publisher.
ISBN 981-238-063-9
ISBN 981-238-064-7 (pbk)
Preface v
4. Applications 25
Index 111
Chapter 1
In the process of solving a counting problem, there are two very simple
but basic principles that we always apply. They are called the Addition
Principle and the Multiplication Principle. In this chapter, we shall
introduce the former and illustrate how it is applied.
Let us begin with a simple problem. Consider a 4-element set A =
{a,b,c,d}. In how many ways can we form a 2-element subset of A1
This can be answered easily by simply listing all the 2-element subsets:
{a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d} .
Thus, the answer is 6.
Let us try a slightly more complicated problem.
Example 1.1 A group of students consists of 4 boys and 3 girls. How
many ways are there to select 2 students of the same sex from the groupl
Solution As the problem requires us to select students of the same
sex, we naturally divide our consideration into two distinct cases: both
of the two students are boys, or, both are girls. For the former case,
this is the same as selecting 2 elements from a 4-element set. Thus, as
shown in the preceding discussion, there are 6 ways. For the latter case,
assume the 3 girls are g\, g% and #3. Then there are 3 ways to form such
a pair; namely,
= i£14
=l
The Addition Principle 3
Example 1.2 From town X to town Y, one can travel by air, land or
sea. There are 3 different ways by air, A different ways by land and 2
different ways by sea as shown in Figure 1.1.
air
Figure 1.1
|Ai| = 3, |A 2 | = 4 and |A 3 | = 2.
Note that AiDA2 = AinA3 = A2(~)A3 = <j> and AiLiA2UA3 is the set of
ways from X to Y. Thus, the required number of ways is IA1U.A2UVI3I,
which, by (AP), is equal to
|i4i| + |Ai| + |i4i| = 3 + 4 + 2 = 9. •
Figure 1.2
4 Counting
Solution The squares in the array can be divided into the following
4 sets:
A\: the set of 1x 1 squares,
Aim. the set of 2x 2 squares,
A3: the set of 3x 3 squares, and
A±: the set of 4x 4 squares.
There are sixteen "1 x 1 squares". Thus \A\\ = 16. There are nine "2 x 2
squares". Thus IA2I = 9. Likewise, |A 3 | = 4 and |A 4 | = 1.
Clearly, the sets A\, A2, A3, A4 are pairwise disjoint and A\ U A% U
A3 U A4 is the set of the squares contained in the array of Figure 1.2.
Thus, by (AP), the desired number of squares is given by
Uti^ = E t i \M = 16 + 9 + 4 + 1 = 30. •
Example 1.4 Find the number of routes from X toY in the one-way
system shown in Figure 1.3.
Figure 1.3
Let us, however, see how to apply (AP) to introduce a more general
method.
Call a route from X to Y an X—Y route. It is obvious that just
before reaching Y along any X—Y route, one has to reach D, E, F or G.
Thus, by (AP), the number of X—Y routes is the sum of the numbers
of X—D routes, X—E routes, X—F routes and X—G routes.
How many X—D routes are there? Just before reaching D along any
X—D route, one has to reach either A or B, and thus, by (AP), the
number of X—D routes is the sum of the numbers of X—A routes and
X—B routes. The same argument applies to others (X—E routes,...)
as well.
G(2)
It is clear that the number of X—A routes (X—B routes and X—C
routes) is 1. With these initial values, one can compute the numbers of
X—D routes, X—E routes, etc., using (AP) as explained above. These
are shown in brackets at the respective vertices in Figure 1.4. Thus, we
see that the total number of possible X—Y routes is 2 + 3 + 3 + 2,
i.e. 10. •
6 Counting
Exercise
1.7 How many squares are there in the following configuration (where
each cell is a square with diagonals)?
1.8 Following the arrows given in the diagram, how many different
routes are there from N to S?
1.9 Following the arrows given in the diagram, how many different
routes are there from N to 5?
/iX / X ^iX
This page is intentionally left blank
Chapter 2
Mr. Tan is now in town X and ready to leave for town Z by car. But
before he can reach town Z, he has to pass through town Y. There are
4 roads (labeled 1, 2, 3, 4) linking X and Y, and 3 roads (labeled as a,
b, c) linking Y and Z as shown in Figure 2.1. How many ways are there
for him to drive from X to Zl
Figure 2.1
Mr. Tan may choose road " 1 " to leave X for Y, and then select "a"
from Y to Z. For simplicity, we denote such a sequence by (I, a). Thus,
by listing all possible sequences as shown below:
(l,a),(l,6),(l,c),
(2, a), (2,6), (2, c),
(3,a),(3,6),(3,c),
(4, a), (4, b), (4, c),
9
10 Counting
Example 2.1 How many ways are there to select 2 students of dif-
ferent sex from a group of 4 boys and 3 girls?
E2
Figure 2.2
The Multiplication Principle 11
Solution The situation when the 2 students chosen are of the same
sex was discussed in Example 1.1. We now consider the case where the 2
students chosen are of different sex. To choose 2 such students, we may
first choose a boy and then select a girl. There are 4 ways for step 1
and 3 ways for step 2 (see Figure 2.2). Thus, by the Multiplication
Principle, the answer is 4 x 3 (= 12). D
The Addition Principle can be expressed using set language. The
Multiplication Principle can likewise be so expressed. For the former,
we make use of the union AU B of sets A and B. For the latter, we shall
introduce the cartesian product Ax B of sets A and B. Thus given two
sets A and B, let
AxB = {(x,y) :xeA, yeB};
namely, Ax B consists of all ordered pairs (x,y), where the first coordi-
nate, "x", is any member in the first set A, and the second coordinate,
"y", is any member in the second set B. For instance, if A = {1,2,3,4}
and B = {a, b, c}, then
A x B = {(1, a), (1,6), (1, c), (2, a), (2,6), (2, c), (3, a), (3,6),
(3, c), (4, a), (4, b), (4, c)}.
Assume that A and B are finite sets. How many members (i.e. or-
dered pairs) are there in the set A x B? In forming ordered pairs in
A x B, a member, say "x" in A is paired up with every member in
B. Thus there are \B\ ordered pairs having "x" as the first coordinate.
Since there are \A\ members in A, altogether we have \A\ \B\ ordered
pairs in Ax B. That is,
Principle (2.1) and result (2.2) are two different forms of the same
fact. Indeed, an event E which is split into two events in ordered stages
can be regarded as an ordered pair (a, b), where "a" stands for the first
event and "6" the second; and vice versa.
Likewise, Principle (2.1) can be extended in a very natural way as
follows:
12 Counting
Then
Figure 2.3
complex and these require that we apply the principles together. The
following is an example.
Example 2.4 (Continuation of Example 2.3) Find the number of
triangles that can be formed using the 9 fixed points of Figure 2.4 as
vertices.
Solution This problem is clearly more complex than that of Exam-
ple 2.3 as there are other triangles whose three vertices are not neces-
sarily chosen from three different sides; but then, where else can they
be chosen from? The answer is: two from one side and one from the
remaining two sides. In view of this, we shall now classify the required
triangles into the following two types.
Type 1 — Triangles whose three vertices are chosen from three different
sides.
As shown in Example 2.3, there are 3 x 4 x 2 (= 24) such
triangles.
Type 2 — Triangles having two vertices from one side and one from the
other two sides.
We further split our consideration into three subcases.
(i) Two vertices from AB and one from BC or CA.
There are 3 ways to choose two from AB (namely,
{a,b},{a,c} or {b, c}) and 6 ways to choose one from
the other sides (namely, d,e,f,g,h,i). Thus, by (MP),
there are 3 x 6 (= 18) such triangles,
(ii) Two vertices from BC and one from CA or AB.
There are 6 ways to choose two from BC (why?) and
5 ways to choose one from the other sides (why?). Thus,
by (MP), there are 6 x 5 (= 30) such triangles,
(iii) Two vertices from CA and one from AB or BC.
There is only one way to choose two from CA and there
are 7 ways to choose one from the other sides. Thus, by
(MP), there are 1 x 7 (= 7) such triangles.
Summing up the above discussion, we conclude that by (AP), there are
18 + 30 + 7 (= 55) triangles of Type 2.
The Multiplication Principle 15
Exercise
2.1 Following the arrows given in the diagram, how many different
routes are there from W to E?
W
y
2.2 In the following figure, ABCD and FEC are two perpendicular
lines.
B D
(a + b)(p + q) = ap + aq + bp + bq .
Counting
(i) How many line segments are there joining any two points,
each point being from a different side of the triangle?
(ii) How many triangles can be formed from these points?
(iii) How many quadrilaterals can be formed from these points?
Chapter 3
There are 25 students in the class. How many ways are there to choose
5 of them to form a committee? If among the chosen five, one is to be
the chairperson, one the secretary and one the treasurer, in how many
ways can this be arranged? In this chapter, our attention will be focused
on the counting problems of the above types. We shall see how (MP)
is used to solve such problems, and how (MP), by incorporating (AP),
enables us to solve more complicated problems.
From now on, for each natural number n, we shall denote by N n the
set of natural numbers from 1 to n inclusive, i.e.,
Nn = { l , 2 , 3 , . . . , n } .
Table 3.1
0 <t> 1
1 {1}, {2}, {3}, {4} 4
2 {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4} 6
3 {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4} 4
4 {1, 2, 3, 4} 1
17
18 Counting
{1,2},{1,3},{1,4},{1,5},{2,3},{2,4},{2,5},{3,4},{3,5},{4,5} ,
and see that there are 10 in total. Thus, we have (2) = 10.
You may ask: How about ( 6 )? We are sure that we are too busy
to have time to compute ( 6 ) by listing all the 6-element subsets of
Nioo- Thus, a natural question arises: Is there a more efficient way to
compute (1060)? The answer is "Yes", and we are going to show you.
Let us first consider a different but related problem. How many
ways are there to arrange any three elements of N4 = {1,2,3,4} in a
row? With a little patience, we can list all the required arrangements
as shown in Table 3.2.
Table 3.2
123 132 213 231 312 321
124 142 214 241 412 421
134 143 314 341 413 431
234 243 324 342 423 432
Subsets and Arrangements 19
Thus, there are 24 ways to do so. The answer is "correct" but the
method is "naive". Is there a cleverer way to get the answer?
Imagine that we wish to choose 3 numbers from N4 and put them
one by one into 3 spaces as shown.
(T 1, 2, 3, ...,n 1
Figure 3.1
20 Counting
n! = n ( n - l ) ( n - 2 ) . . . 3 - 2 - l (3.2)
That is,
(3.3)
n!
" {n-n)\ 0!
i.e.,
P n n = «!- (3.4)
definition, ("), while that for the second step is, by (3.4), r\. Thus, by
(MP), we have
r?=[nri-«
As
p n = rc!
r
(n - r)\ '
we have
n \ n!
•r! = (n — r)\ '
and thus
(3.5)
For instance,
; - i - ; , . i .
= 1.
By applying (3.5), one can show that the following identity holds (see
Problem 3.1):
(3.6)
Exercise
Applications
Example 4.1 There are 6 boys and 5 men waiting for their turn in a
barber shop. Two particular boys are A and B, and one particular man
is Z. There is a row of 11 seats for the customers. Find the number of
ways of arranging them in each of the following cases:
z
25
26 Counting
b m b m b m b m b m b
The boys can be placed in 6! ways and the men can be placed in 5!
ways. By (MP), the desired number of ways is 6!5!. D
Example 4.2 In each of the following cases, find the number of inte-
gers between 3000 and 6000 in which no digit is repeated:
(i) there are no additional restrictions;
(ii) the integers are even.
{3,4,5}
A b e d
In this case, d has 5 choices, and the number of ways to form "fee" is
Pf. The required number of integers is 2 • 5 • Pf.
By (AP), the desired number of integers is
4 • P28 + 2 • 5 • Pf = 14 • P 2 8 . D
Example 4.3 There are 10 pupils in a class.
(i) ffou; many ways are there to form a 5-member committee for the
class?
(ii) How many ways are there to form a 5-member committee in which
one is the Chairperson, one is the Vice-Chairperson, one is the
Secretary and one is the Treasurer?
(iii) How many ways are there to form a 5-member committee in
which one is the Chairperson, one is the Secretary and one is the
Treasurer?
Solution (i) This is the same as finding the number of 5-combinations
of a 10-element set. Thus the answer is ( 5 ) = 252.
(ii) This is the same as choosing 5 pupils from the class and then placing
them in the following spaces.
Figure 4.1
28 Counting
e.g. 0 0
1 0 1 0 1 1
Figure 4.2
Applications 29
Solution (i) Every chord joins two of the nine points, and every two
of the nine points determine a unique chord. Thus, the required number
of chords is (2).
If you revisit Example 2.4, you may then observe that the problem
can also be solved by (CP). There are (3) ways to form a 3-vertex subset
from the given 9 vertices. Among them, the 3 on AB and any 3 on BC
do not form a triangle. Thus, the number of triangles one can form is,
by (CP),
which is 79.
We have seen from the above examples how, by applying (CP), we
are able to considerably shorten the work needed to solve a counting
problem. When a direct approach involves a large number of cases for
which a certain condition holds, the complementary view of the smaller
number of cases in which the condition does NOT hold allows a quicker
solution to the problem. What follows then is that we count the number
of ways afforded by the smaller number of "complementary" cases and
Applications 31
finally obtain the required answer by subtracting this from the total
number of ways.
Exercise
4.5 Three girls and seven boys are to be lined up in a row. Find the
number of ways this can be done if
(i) there is no restriction;
(ii) the girls must form a single block;
(iii) no two girls are adjacent;
(iv) each boy is adjacent to at most one girl.
4.6 Eight students are in a sailing club. In how many ways can they
form a team consisting of 4 Laser pairs, where the order of the
pairs does not matter? (Note: A Laser is a sailing boat that
takes a crew of two.)
4.7 There are three boys and two girls.
(i) Find the number of ways to arrange them in a row.
(ii) Find the number of ways to arrange them in a row so that
the two girls are next to each other,
(iii) Find the number of ways to arrange them in a row so that
there is at least one boy between the two girls.
4.8 In how many ways can a committee of 5 be formed from a group
of 11 people consisting of 4 teachers and 7 students if
(i) the committee must include exactly 2 teachers?
(ii) the committee must include at least 3 teachers?
(iii) a particular teacher and a particular student cannot be both
in the committee?
4.9 A palindrome is a number that remains the same when it is read
backward, for example, 2002 is a palindrome. Find the number
of n-digit palindromes.
4.10 A team of 6 people is to be chosen from a list of 10 candidates.
Find in how many ways this can be done
(i) if the order of the people in the team does not matter;
(ii) if the team consists of 6 people in a definite order;
(iii) if the team consists of a first pair, a second pair and a third
pair but order within each pair does not matter. /rr.
\SJ)
4.11 Find how many three figure numbers, lying between 100 and 999
inclusive, have two and only two consecutive figures identical.
(C)
Applications 33
A A A A .Qt
J?k y*Tk jyy J5L25L Figure 5.1
f:A^B,
35
36 Counting
(i) Ai Bi
(ii) A2 B2
(iii) A3 B3
(iv) A4 B4
Figure 5.2
The Bijection Principle 37
fx and /3 are not (why?). We say that / is surjective (or onto) if for any
b in B, there exists an a in A such that / ( a ) = b. Thus, in Figure 5.2,
/3 and /4 are surjective whereas / i and /2 are not (why?). We call / a
bijection from A to £? if / is both injective and surjective. (Sometimes,
a bijection from A to 5 is referred to as a one-to-one correspondence
between A and J5.) Thus, in Figure 5.2, f\ is the only bijection. These
observations on the four mappings are summarized in Table 5.1.
Table 5.1
h X X X
h / X X
h X / X
U / / /
\A\ = \B\.
38 Counting
Figure 5.3
•U,5}
5
> {2,4}
Figure 5.4
The Bijection Principle 39
a- ->{1,2,3,5)
b- ->U,2,4,5}
c- ->{1,3,4,5}
d- ->{2,3,4,5}
e- ->{1,2,3,4}
Figure 5.5
— • —
^ T
.r
1
PO
Figure 5.6
40 Counting
-> 010100
P •-
_J -> 000101
and so on.
Now, let A be the set of all shortest P—Q routes and B, the set of
all 6-digit binary sequences with two l's. Then we see that the above
way of representing a shortest P—Q route in A by a binary sequence
in B defines a mapping / : A -> B. Clearly, different shortest P—Q
routes in A correspond to different sequences in B under / . Thus, / is
one-to-one. Further, for any sequence b in B, say, b = 100010, one can
find a shortest P—Q route, a in A, in this case,
-%Q
r
The Bijection Principle 41
Example 5.2 The power set of a set S, denoted by V(S), is the set
of all subsets of S, inclusive of S and the empty set (j). Thus, for N n =
{1,2,... ,n}, 1 < n < 3, we have
V(N1) = {<P,{1}},
Solution For convenience, let A = 73(N5); that is, A is the power set
of {1,2,3,4,5}. Represent these subsets by 5-digit binary sequences as
follows:
4> • ooooo
{1} • 10000
{2} • 01000
{1,2} • 11000
{4,5} •00011
{1,3,5} • 10101
The rule is that the ith digit of the corresponding binary sequence is
"1" if "i" is in the subset; and "0" otherwise. Let B be the set of all
5-digit binary sequences. Clearly, the above rule establishes a bijection
between A and B. Thus, by (BP), |A| = |B|. Since | B | = 2 5 (see
Example 2.2), \A\ = 2 5 . D
Note that |P(Ni)| = 2 = 2!, |P(N 2 )| = 4 = 2 2 , |P(N 3 )| = 8 = 2 3 ,
|7>(N4)| = 16 = 2 4 , and now |P(N 5 )| = 2 5 . What is |P(N„)| for n > 1?
(See Exercise 5.3.)
Finally, let us introduce a counting problem related to the notion of
divisors of natural numbers. We shall denote by N, the set of natural
numbers; i.e.
N = {1,2,3,...}.
Assume that d,n € N. We say that d is a divisor of n if when n is
divided by d, the remainder is zero. Thus, 3 is a divisor of 12, 5 is a
divisor of 100, but 2 is not a divisor of 9.
Let n € N, n > 2. Clearly, n has at least two divisors, namely 1 and
n. How many divisors (inclusive of 1 and n) does n have? This is a
type of problem that can often be found in mathematical competitions.
We shall tackle this problem and see how (MP) and (BP) are used in
solving the problem.
To understand the solution, we first recall a special type of numbers
called prime numbers and state an important result relating natural
numbers and prime numbers.
A natural number p is said to be prime (or called a prime) if p > 2
and the only divisors of p are 1 and p. All prime numbers less than 100
are shown below:
2,3,5,7,11,13,17,19,23,29,31,37,41,
43,47,53,59,61,67,71,73,79,83,89,97.
The primes are often referred to as building blocks of numbers
because every natural number can always be expressed uniquely as a
product of some primes. For example,
108 = 2 2 x 3 3 , 1620 = 2 2 x 3 4 x 5 ,
1815 = 3 x 5 x l l 2 , 215306 = 2 x 7 2 x 13 3 .
The Bijection Principle 43
n = p?W •Pkk
for some distinct primes pi,P2, • • • ,Pk a n d for some natural numbers
mi, m,2,..., mk. Such a factorization is unique if the order of primes
is disregarded.
FTA was first studied by the Greek mathematician, Euclid (c. 450-
380 BC) in the case where the number of primes is at most 4. It was
the German mathematician, Carl Friedrich Gauss (1777-1855), known
as the Prince of Mathematicians, who stated and proved the full result
in 1801.
Let us now return to the problem of counting the number of divisors
of n. How many divisors does the number 72 have? Since 72 is not a big
number, we can get the answer simply by listing all the divisors of 72:
1,2,3,4,6,8,9,12,18,24,36,72.
The way of counting the divisors of n by listing as shown above is
certainly impractical when n gets larger. We look for a more efficient
way.
Let us look at the example when n = 72 again and try to get some
information about 72 and its divisors by FTA.
!
2&s%
The images above are those of Euclid on a stamp of the Maldives and Gauss on a
German banknote.
44 Counting
x = 2px3«
where, clearly, p E {0,1,2,3} and q € {0,1, 2}. On the other hand, any
such number 2P x 3 9 is a divisor of 72. Indeed,
1 = 2° x 3° 9 = 2° x 32 ,
2 = 21 x 3° 12 = 2 2 x 31,
3 - 2° x 31 18 = 21 x 32 ,
4 = 2 2 x 3° 24 = 2 3 x 3 1 ,
6 = 21 x 31 36 = 2 2 x 32 ,
8 = 2 3 x 3° 72 = 23 x 32 .
Let A be the set of divisors of 72 and B = {{p,q) : 0 < p < 3,0 <
q < 2} = {0,1,2,3} x {0,1,2}. Then the above list implies that the
mapping / defined by
z = 2° x 3 6 x 5C x 7d
The Bijection Principle 45
where a,b,c,d are integers such that 0 < a < 3 , 0 < 6 < 2 , 0 < c < 2
and 0 < d < 1.
Let A be the set of divisors z of 12600 and B = {(a,b,c,d) : a —
0,1,2,3; 6 = 0,1,2; c = 0,1,2; d = 0,1}. Clearly, the mapping / denned
by
f{z) = (a,b,c,d),
Exercise
Q
vc
«
\\ft uB
%t
<
p
46 Counting
4=4=1+3
=3+1=2+2
=1+1+2=1+2+1
= 2 + 1 + 1 = 1 + 1 + 1 + 1.
Show that every natural number n can be so expressed in 2 n _ 1
ways.
5.6 How many rectangles are there in the following 6 x 7 grid?
Figure 6.1 shows three distinct boxes into which seven identical
(indistinguishable) balls are to be distributed. Three different ways
of distribution are shown in Figure 6.2. (Note that the two vertical bars
at the two ends are removed.)
Figure 6.1
(a)
OOOO OO O
(b)
OO O O OOO
(c)
oooooo
Figure 6.2
47
48 Counting
first step to be done is 1. On the other hand, by the result (6.1), the
number of ways to do the second step is
(r — n) + n — 1
n-1
Example 6.1 There are 11 men waiting for their turn in a barber
shop. Three particular men are A, B and C. There is a row of 11 seats
for the customers. Find the number of ways of arranging them so that
no two of A, B and C are adjacent.
Solution There are different ways to solve this problem. We shall see
in what follows that it can be treated as a distribution problem.
First of all, there are 3! ways to arrange A, B and C. Fix one of the
ways, say A—B—C. We then consider the remaining 8 persons. Let us
imagine tentatively that these 8 persons are identical, and they are to be
placed in 4 distinct boxes as shown in Figure 6.3 so that boxes (2) and
(3) are not vacant (since no two of A,B and C are adjacent). To meet
this requirement, we place one in box (2) and one in box (3). Then the
remaining six can be placed freely in the boxes in i6^^1) = (jj) ways
by (6.1). (Figure 6.4 shows a way of distribution.)
Oo
o
ooo
S~
o B o
(1) (2) (3) (4)
Figure 6.3
50 Counting
QO A OO B O C OOP
(1) (2) (3) (4)
Figure 6.4
But the eight persons are actually distinct. Thus, to each of these
(3) ways, there are 8! ways to arrange them.
Hence by (MP), the required number of ways is 3!(3)8!, which is
8! 9 • 8 • 7. •
X\ X2 X-} X4 X$ ^6 X7 Xg
(1) (2) (3) (4) (5) (6) (7) (8) (9)
X\ X2 X3 A A4 X5 X$ X-] Xg
HT ~W (3) (4) (5) ~W ~W (8) (9)
Next, consider B. Since A and B cannot be adjacent, B can be placed
only in one of the remaining 8 boxes. Likewise, C can be placed only in
one of the remaining 7 boxes. The answer is thus 8! 9 • 8 • 7.
Exercise
53
54 Counting
Figure 7.1
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
{1,3,8} - + 1 0 1 0 0 0 0 1 0 0
{3,6,10} - + 0 0 1 0 0 1 0 0 0 1
More Applications of (BP) 55
Note that the rule is similar to the one introduced in Example 5.2.
Clearly, this correspondence is a bijection between the set A of 3-element
subsets of Nio satisfying (3) and the set B of 10-digit binary sequences
with three l's in which no two l's are adjacent. Thus \A\ = \B\. But
how do we count \B\1 Using the method discussed in Example 6.1, we
obtain
w-C?-*4-1)-®-
Thus |A| = (5). •
Example 7.3 Two tennis teams A and B, consisting of 5 players
each, will have a friendly match playing only singles tennis with no ties
allowed. The players in each team are arranged in order:
A : ai,a2,a 3 ,a 4 ,a5 ,
B : h,b2,b3,b4,b5.
The match is run in the following way. First, a\ plays against b\. Sup-
pose ai wins (i.e. b\ is eliminated). Then a\ continues to play against
62; if ai is beaten by 62 (&-e. a\ is eliminated), then 62 continues to play
against a2, and so on. What is the number of possible ways in which all
the 5 players in team B are eliminated? (Two such ways are shown in
Figure 7.2.)
Solution Let Xi be the number of games won by player a^, i —
1,2,3,4,5. Thus, in Figure 7.2(i),
x\ = 2, £2 = 0 j £3 = 3 , £4 = X5 = 0
and in Figure 7.2(h),
xi = x2 — 0, X3 = 2 , £4 = 1, £5 = 2.
In order for the 5 players in team B to be eliminated, we must have
xi + x2 + x3 + £4 + x5 = 5 (4)
and the number of ways this can happen is, by (BP), the number
of nonnegative integer solutions to (4). Thus, the desired answer is
( 5 + 4 - 1 ) = (4),bytheresult7.1(i). •
56 Counting
b\ b2 b3 b4 b5
(i)
a\ ai an, a± a$
\AAAA
b\ 62 ^3 i>4 b$
(ii)
"o ->• 6" means "a beats 6"
Figure 7.2
Example 7.4 Eight letters are to be selected from the five vowels
a,e,i,o,u with repetition allowed. In how many ways can this be done
if
(i) there are no other restrictions?
(ii) each vowel must be selected at least once?
Solution (i) Some examples of ways of the selection are given below:
(1) a,a,u,u,u,u,u,u;
(2) a, e,i,i,i,o, o, u;
(3) e,e,i,i,o,o,u,u.
Thus, by (BP) and the result (6.1), the number of ways of selection
is given by f ^ - 1 ) , i.e. ft2).
(ii) As shown in the second row of Figure 7.3, a way of selection
which includes each vowel can be treated as a way of distribution such
that no box is empty. Thus, by (BP) and the result (6.2), the number
of ways of selection is given by (g~g), i.e. Q . •
Example 7.5 Consider the following two 13-digit binary sequences:
1110101110000,
1000110011110.
For binary sequences, any block of two adjacent digits is of the form
00,01,10 or 11. In each of the above sequences, there are three 00, two
01, three 10 and four 11. Find the number ofl3-digit binary sequences
which have exactly three 00, two 01, three 10 and four 11.
For instance, the two sequences given in the problem are of the form:
1 1 | 000 | 11 1 00 1 1111 | 0 |
(1) (2) (3) (4) (5) (6)
(i) put in three more 0's in boxes (2), (4) or (6) (but in an arbitrary
way), and
(ii) put four more l's in boxes (1), (3) or (5) (also in an arbitrary way).
58 Counting
(i)
B,
-> ABCDE- -> BCDE
'D
->ACBDE- ->CBDE
Figure 7.5
Exercise
£i + ^2 + ^3 + X4 — 30
in each of the following cases:
(i) Xi > 0 for each i = 1,2,3,4;
(ii) 2 < x\ < 7 and Xi > 0 for each i = 2,3,4;
(iii) x\ > —5,X2 > —1,0:3 > 1 and £4 > 2.
7.5 Find the number of quadruples (w, x, y, z) of nonnegative integers
which satisfy the inequality
w + x + y + z < 2002.
7.6 Find the number of nonnegative integer solutions to the equation:
5a:i + x2 + 23 + £4 = 14.
7.7 There are five ways to express 4 as a sum of two nonnegative
integers in which the order matters:
4=4+0=3+1=2+2=1+3=0+4.
More Applications of (BP) 61
/r + n - 3 \ fr + n-2\
( , - , ) + ( r J'
7.12 In a new dictatorship, it is decided to reorder the days of the
week using the same names of the days. All the possible ways of
doing so are to be presented to the dictator for her to decide on
one. How many ways are there in which Sunday is immediately
after Friday and immediately before Thursday?
7.13 Five couples occupy a round table at a wedding dinner. Find the
number of ways for them to be seated if:
(i) every man is seated between two women;
62 Counting
(ii) every man is seated between two women, one of whom is his
wife;
(iii) every man is seated with his wife;
(iv) the women are seated on consecutive seats.
7.14 The seats at a round table are numbered from 1 to 7. Find the
number of ways in which a committee consisting of four men and
three women can be seated at the table
(i) if there are no restrictions;
(ii) if all the men sit together. ,„-.
7.15 Four men, two women and a child sit at a round table. Find
the number of ways of arranging the seven people if the child is
seated
(i) between the two women;
(ii) between two men. ,_,*
Chapter 8
We have considered Case (1) in Chapters 6 and 7. Cases (3) and (4) will
not be touched upon in this booklet. In this chapter, we shall consider
Case (2).
Suppose that 5 distinct balls are to be put into 7 distinct boxes.
Example 8.1 In how many ways can this be done if each box can
hold at most one ball?
Example 8.2 In how many ways can this be done if each box can
hold any number of balls?
63
64 Counting
I
(1) (2) (3) (4) (5) (6) (7)
Figure 8.1
Next, we consider b (say). As each box can hold at most one ball,
and one of the boxes is occupied by a, there are now 6 choices for
b. Likewise, there are, respectively, 5, 4 and 3 choices for c, d and
e. Thus, by (MP), the number of ways of distribution is given by
7-6-5-4-3.
Note that the above answer can be expressed as P j which, as denned
in Chapter 3, is the number of ways of arranging any 5 objects from
7 distinct objects. The fact that the above answer is P j does not sur-
prise us as there is a 1-1 correspondence between the distributions of
5 distinct balls into 7 distinct boxes and the arrangements of 5 distinct
objects from 7 distinct objects as shown in Figure 8.2. (Find out the
rule of the correspondence.)
{a,b,c,d,e} {1,2,3,4,5,6,7}
b c a e d -> 41275
e d c b a -> 74321
(1) (2) (3) (4) (5) (6) (7)
Figure 8.2
Distribution of Distinct Objects into Distinct Boxes 65
In general, we have:
Exercise
| de \ ab c \ | [ ed \ cba | |
(1) (2) (3) (1) (2) (3)
Figure 9.1
67
68 Counting
Figure 9.3
00 000
(1) (2) (3)
Since the 5 objects are actually distinct and the ordering of objects mat-
ters, such a distribution for identical objects corresponds to 5! different
distributions of distinct objects. Thus, by (MP), the answer is given by
(2) • 5! which agrees with the answer 3 • 4 • 5 • 6 • 7.
In general, we have:
Other Variations of the Distribution Problem 69
(9.1)
which is equal to
n(n + l)(n + 2 ) . . . (n + r - 1).
Figure 9.4
There are Q ways for step 1, (3) ways for step 2 and (%)(= 1) way for
step 3. Thus, by (MP), the answer is given by
70 Counting
1a c a b a a b b c | <- acabaabbc
1c c b b b a a a a I <- ccbbbaaaa
Figure 9.5
be a dc ; > be\a\dc
cde ba : > cde 11 ba
Figure 9.6
Exercise
9.1 Calculate the number of different arrangements which can be made
using all the letters of the word BAN AN ARAM A.
9.2 Calculate the number of distinct 8-letter arrangements which can
be made with letters of the word INFINITE. How many of these
begin with III?
(C)
9.3 Find the number of arrangements of 4 identical squares, 5 identical
pentagons and 6 identical hexagons in a row if
(i) there is no restriction;
(ii) no two pentagons are adjacent;
(iii) any two squares are separated by at least two other polygons.
9.4 Let A = { 1 , 2 , . . . , m} and B = { 1 , 2 , . . . , n} where m, n > 1. Find
the number of
(i) mappings from A to B;
(ii) 1-1 mappings from A to B (here m < n);
(iii) mappings f : A —t B such that /(«') < f(j) in B whenever
i < j in A (here m < n);
(iv) mappings f : A-* B such that / ( l ) = 1.
9.5 Let A = { 1 , 2 , . . . , m} and B = { 1 , 2 , . . . , n}. Find the number of
onto mappings from A to B in each of the following cases:
(i) m = n;
(ii) m = n + 1;
(iii) m = n + 2.
(Compare this problem with Problem 8.5.)
9.6 Ten cars take part in an Automobile Association of Singapore
autoventure to Malaysia. At the causeway, 4 immigration counters
are open. In how many ways can the 10 cars line up in a 4-line
queue?
72 Counting
9.7 Solve Problem 8.5 with an additional condition that the ordering
of objects in each box counts.
9.8 Show that
n\ (n — ni\ (n — ni — • • • — rik-\\ n\
n
n\) \ 712 / V h ) n\\n^. • • • n\^.
where n = n\ + ni -\ 1- n^.
Chapter 10
(10.1)
(10.2)
\r J \n — r J '
0 -C-lH'r 1
)- (10.3)
1 2 1
(10.4)
( - ( - l ) - ' -
73
74 Counting
(10.5)
(1 + *)° = 1,
(l + x)1 = l + xt
(1 + x)2 = 1 + 2x + x2,
(1 + x)3 = 1 + 3x + 3x 2 + x 3 .
Notice that the coefficients in the above expansions are actually numbers
of the form ("). Indeed, we have:
Table 10.1
X X
Observe that in the expansion, each of the factors (1), (2), (3) and (4)
contributes either 1 o n , and they are multiplied together to form a
term. For instance, to obtain x2 in the expansion, two of (1), (2), (3)
and (4) contribute x and the remaining two contribute 1. How many
ways can this be done? Table 10.1 shows all the possible ways, and the
answer is 6.
Thus, there are 6 terms of a;2 and the coefficient of a;2 in the expansion
of (1 + x) 4 is therefore 6. Indeed, to select two x's from four factors
(1 + x), there are (*,) ways (while the remaining two have no choice
but to contribute "1"). Thus the coefficient of x 2 in the expansion of
(1 + x) 4 is (2) which is 6. Using a similar argument, one can readily see
that
Exercise
(n) oo = {r)Cz)-
10.2 In the expansion of (1 + x) 1 0 0 , it is known that the coefficients of
xr and x3r, where 1 < r < 33, are equal. Find the value of r.
10.3 What is the largest value of k such that there is a binomial ex-
pansion (1 + x)n in which the coefficients of k consecutive terms
are in the ratio 1 : 2 : 3 : . . . : kl Identify the corresponding
expansion and the terms.
Chapter 11
0-element subsets of S is
CD
1-element subsets of S is
"
77
78 Counting
2-element subsets of S is n
Thus,
n-element subsets of S is
0
n n
\ns)\ = +1 l )+ + ••• +
(by (Bl)) •
Example 11.2 The number 4 can be expressed as a sum of one or
more positive integers, taking order into account, in the following 8
ways:
4=4=1+3
=3+1=2+2
=1+1+2=1+2+1
= 2 + 1 + 1 = 1 + 1 + 1 + 1.
Show that every natural number n can be so expressed in 2 n _ 1 ways.
Solution This is in fact Problem 5.5. Let us see how (Bl) can be
used to prove the result. But first of all, consider the special case above
when n = 4.
We write 4 = 1 + 1 + 1 + 1 and note that there are three "+"s in the
expression. Look at the following relation.
4 <—y 1 + 1 + 1 + 1 (no "+" is chosen)
4
l + l + 2<—• 1 i 1 ®1+1
1 1 2
1 + 2 + 1 ^—> 1 i + ie l (2 "+"s are chosen)
l 2 1
2 + 1 + 1 <—n + i e l © I
2 1 1
1+ 1 + 1 + 1^—>-^l^©l©l (3 "+"s are chosen)
1 1 1
; • : + « • : > - * •
In general, write
n = l + l + --- + l + l
" v '
n
and note that there are n — 1 "+"s in the above expression. We now
extend the above technique by establishing a bijection between the set
of all such expressions of n and the set of all subsets of n — 1 "+"s.
Thus, by (BP) and (Bl), the number of all such expressions of n is
n - l \ (n — \ \ (n — \ \ „_i
+ + + 1=2 D
o i - U-i
Consider again the expansion of (1 + x)n in (BT). If we now let
x — — 1, we then have
where the terms on the LHS alternate in sign. Thus, if n is even, say
n = 2k, then
n \ (n ,
o) +
( 2
l +
- +
U) - (" + f
3 +
- +
Ufc-1
80 Cc writing
+ + + = 2n
[(:)•(;)••••] [Q G) -]
by (Bl), we have:
c; + it + e !+•
n
= -(2 ) = 2 " -1
.
e +-
(B2)
Li
By (B2),
!+G'+
'8
0 + + ••• +
+
= 2 8 _ 1 .= 2 7 = 128. •
Consider the following binomial expansion once again:
(1 + x)n = n n n n z3 + n
+ l1)*+l2l*' + + n
x
Some Useful Identities 81
^i+.r- = (-)+8(;),+,(;)^+...+-(;)^-.
By letting x — 1 in the above identity, we have:
n
In * fn \
E*l -f? )+2| | + » | c n ^l + - • + n ( ' : )
k=i
\ k i 3
= n2 n "-1
A A
B B
C C
A, B A
A, B B
A, C A
A, C C
B, C B
B, C C
82 Counting
A, B, C A
A, B, C B
A, B, C C
Ek
fc=i
Let us count the same problem via a different approach as follows.
First, we select a leader from the group, and then choose k — 1 members,
where k = 1,2,..., n, from the group to form a fc-member committee.
There are n choices for the first step and
n-1 n 1 n —l
4- + ••• +
0 n-1
ways for the second step. Thus, by (MP) and (Bl), the required number
is
n-1 n-1 n-1 = n2"_1
n 0 + + ••• +
n-1
Since both
and n2,n—1
fc=l
count the same number, identity (B3) follows.
In the above discussion, we establish identity (B3) by first intro-
ducing a "suitable" counting problem. We then count the problem in
two different ways so as to obtain two different expressions. These two
Some Useful Identities 83
Exercise
k=r
11.2 Show that
n-1
£(V)-
fc=0 V y
o2n-2
f>s(Y)=n(n+1)2"-*.
v J
fc=l
Pascal's Triangle
( i+ *> B =E(?y
r=0 ^ '
Let us display the binomial coefficients row by row following the
increasing values of n as shown in Figure 12.1. We observe from
Figure 12.1 the following.
1. The binomial coefficient at a lattice point counts the number of
shortest routes from the top lattice point (representing (g)) to the
lattice point concerned. For example, there are (2) (= 6) shortest
Figure 12.1
85
86 Counting
routes from the lattice point representing (Q) to the lattice point (2)
(also see Example 5.1).
2. The number pattern is symmetric with respect to the vertical line
through the top lattice point, and this observation corresponds to
the identity (?) = ( ^ r ) (see (10.2)).
3. Any binomial coefficient represented by an interior lattice point is
equal to the sum of the two binomial coefficients represented by the
lattice points on its "shoulders" (see Figure 12.2). This observation
corresponds to the identity (?) = (?~J) + (n;1) (see (10.3)).
Figure 12.2
M$ & * & %
At^k^m <wk%*k*&m>m
Figure 12.3
Blaise Pascal
1 1
1 2 1
1 3 3 1
1 4 6 4 1
l 5 10 10 5 1
1 6 IS 20 15 6 1
1 7 21 35 35 21 7
1 8 28 56 70 56 28 8
Figure 12.4
Observe that
. + . + . + » + » + »-G) + G) + G) + G) + (;) + G)
+ +
-G)*G) G)+G)*G) G)
(- G) • G))
+
-G)*G)*G)*G) G)
+
-G) G)*G)*G)
+ +
-G) G) G)
-GMD
-G) (=56)
by applying the identity ( £ } ) + ( n ; x ) = (?).
The above result is really a special case of a general situation. As
a matter of fact, the above argument can also be used to establish the
following general result (also see Figure 12.5):
Pascal's Triangle
Figure 12.5
Figure 12.6
(B4)
Example 12.1 Let 1 < r < n and consider all r-element subsets of
the set { 1 , 2 , . . . ,n}. Each of these subsets has a smallest member. Let
F(n, r) denote the arithmetic mean of these smallest numbers. Prove
that
n+ 1
F(n,r) =
r+1
{1, 2, 3, 4}
{1, 2, 3, 5}
{1, 2, 3, 6}
{1, 2, 4, 5}
{1,2,4,6}
{1, 2, 5, 6}
{1, 3, 4, 5}
{1, 3, 4, 6}
{1, 3, 5, 6}
{1, 4, 5, 6}
{2, 3, 4, 5} 2
{2, 3, 4, 6} 2
{2, 3, 5, 6} 2
{2, 4, 5, 6} 2
{3, 4, 5, 6} 3
By definition,
+ ) •
92 Counting
Now, by applying (B4) to each summand above except the last one
and noting that (£"}) = (£), E can be simplified to
n\ /n —l\ fr
r r r
) V J \
n—r+1
n+ 1
r+ 1
Finally, by definition of F(n,r), it follows that
'n\ /n + l\ (n
F(n,r) = E + . . . , . . .
(n + 1)! r\(n-r)\
(r + l)!(n - r)! n!
_ n+ 1
_
r+ 1
as desired. D
Exercise
(l + x) 5 + (l + x) 6 + --- + (l + x ) 1 0 0 .
Miscellaneous Problems
l EZ~3 ^
2
5 CZD CZZI io
(AIME)
2 Calculate in how many ways each of the following choices can
be made.
(i) 4 books are to be chosen from a list of 10 titles to be taken
away for reading during a holiday.
(ii) 20 people have sent in winning entries for a newspaper
competition, and three are to be chosen and placed in order
of merit so as to receive the 1st, 2nd and 3rd prizes.
95
Counting
25225,33333, 70007,11888,...
every digit appears more than once. Find the number of such
5-digit numbers.
Miscellaneous Problems 97
814736259,569324178,793548216,....
458971263,695438172,854796123,....
—<>
R
i
I I —
98 Counting
13.16 In a shooting match, eight clay targets are arranged in two hang-
ing columns of three each and one column of two, as pictured.
c c
c o 0 c
c 0 u N u o c
c o u N T N u o c0
c 0 u N T I T N u c
o u N T I N I T N u 0
u N T I N G N I T N u
o U N T I N I T N u o
c o U N T I T N U o c
c 0 U N T N U O c
c 0 U N U O c
c 0 U 0 c
c 0 c
c
i ( 1 , 2) (2, 2) (/n-1 , 2 ) i
(0,2) 1 » 1 ii (m, 2)
( 1 , 1) (2, 1) (m-1 1)
(0, D' 1 (m, 1)
» « i < i
000111220011222
012220000111122
Observe that each of the sequences contains exactly three 00,
three 11, three 22, two 01, two 12 and one 20. Find the number
of such ternary sequences.
28 There are n upright cups in a row. At each step, I turn over
n — 1 of them. Show that I can end up with all the cups upside
down if and only if n is even. Find the number of ways this can
be done in a minimum number of steps.
29 The following diagram shows 15 distinct points: toi, W2, u>3,
xi,..., X4, y\,..., y6, z\, Z2 chosen from the sides of rectangle
ABCD.
(i) How many line segments are there joining any two points
each on different sides?
(ii) How many triangles can be formed from these points?
(iii) How many quadrilaterals can be formed from these points?
102 Counting
M>i W2 W3 D
,Xi
Z24
,x2
Z\\ X4
B y* ys y* J3 yi y\
(iii)
-0
Miscellaneous Problems 103
(2) any two vertices which are joined by a line must be coloured
by different colours.
How many different ways are there to colour each configuration?
32 If repetitions are not allowed, find the number of different 5-digit
numbers which can be formed from 0 , 1 , 2 , . . . , 9 and are
(i) divisible by 25;
(ii) odd and divisible by 25;
(iii) even and divisible by 25;
(iv) greater than 75000;
(v) less than 75000;
(vi) in the interval [30000, 75000] and divisible by 5.
33 There are 12 boys and 8 girls, including a particular boy B and
two particular girls G\ and G2, in a class. A class debating team
of 4 speakers and a reserve is to be formed for the inter-class
games. Find the number of ways this can be done if the team
is to contain
105
This page is intentionally left blank
Answers to Exercises
107
108 Counting
Fundamental Theorem of
Arithmetic, 43
injection, 37
Injection Principle, 37
111
COUNTING
This book is a useful, attractive introduction to basic
counting techniques for upper secondary and junior
college students, as well as teachers. Younger students
and lay people who appreciate mathematics, not to
mention avid puzzle solvers, will also find the book
interesting. The various problems and applications
here are good for building up proficiency in counting.
They are also useful for honing basic skills and
techniques in general problem solving. Many of the
problems avoid routine and the diligent reader will
often discover more than one way of solving a
particular problem, which is indeed an importan
awareness in problem solving. The book thus help;
to give students an early start to learning proble
solving heuristics and thinking skills.