Professional Documents
Culture Documents
www.albohessab.weebly.com
The primary technique of counting is to break a complex problem into a sequence of simpler problems.
Additionally, one must understand how to combine the answers to the simple problems to obtain the
desired answer to the complex problem. This chapter introduces one of the most basic tools of counting.
|A ∪ B| = |A| + |B|
Example 1.1 The mathematics department must choose either a student or a faculty member as a
representative for a university committee. How many choices are there for this representative if there
are 37 members of the mathematics faculty and 83 mathematics majors and no one is both a faculty
member and a student.
Solution. There are 37 ways to choose a member of the mathematics faculty and there are 83 ways
to choose a student who is a mathematics major. Choosing a member of the mathematics faculty is
never the same as choosing a student who is a mathematics major because no one is both a faculty
member and a student. By the sum rule it follows that there are 37 + 83 = 120 possible ways to pick this
representative.
2 Chapter 1. Elementary counting principles
Example 1.2 One can reach city Q from city P by sea, air and road. Suppose that there are 2 ways by
sea, 3 ways by air and 2 ways by road (see Figure 1.4). Then by sum rule, the total number of ways from
P to Q by sea, air or road is 2 + 3 + 2 = 7.
www.albohessab.weebly.com
sea
P air
Q
road
Figure 1.1
Example 1.3 A bookshelf holds 6 different English books, 8 different Ge’ez books, and 10 different
Amharic books. There are 6 + 8 + 10 = 24 ways of selecting 1 book in any one of the languages.
Definition 1.1.3 — Product Rule. Suppose that a procedure can be broken down into a sequence of
two tasks. If there are n 1 ways to do the first task and for each of these ways of doing the first task,
there are n 2 ways to do the second task, then there are n 1n 2 ways to do the procedure.
Example 1.4 The chairs of an auditorium are to be labeled with an uppercase English letter followed by
a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently?
Solution. The procedure of labeling a chair consists of two tasks, namely, assigning to the seat one of
the 26 uppercase English letters, and then assigning to it one of the 100 possible integers. The product
rule shows that there are 26 · 100 = 2600 different ways that a chair can be labeled. Therefore, the largest
number of chairs that can be labeled differently is 2600.
1.1 Basic counting principle 3
The following extended version of the product rule is often useful in counting problems.
Definition 1.1.4 — Generalized Product Rule. Suppose that a procedure is carried out by performing
the tasks T1 ,T2 , . . . ,Tk in sequence. If each task Ti , i = 1, 2, . . . , k, can be done in ni ways, regardless
of how the previous tasks were done, then there are n 1 · n 2 · · · nk ways to carry out the procedure.
Example 1.5 To reach city D from city A, one has to pass through city B and city C as shown in Figure
1.2.
www.albohessab.weebly.com
A B C D
Figure 1.2
If there are 2 ways to travel from A to B, 5 ways from B to C, and 3 ways from C to D, then by product
rule, the number of ways from A to D is via B and C is given by 2 · 5 · 3 = 30.
Example 1.6 A bookshelf holds 6 different English books, 8 different Ge’ez books, and 10 different
Amharic books. There are 6 · 8 · 10 = 480 ways of selecting 3 books, 1 in each language.
Example 1.7 The scenario is as in Example 1.6. An English book and a Ge’ez book can be selected in
6 · 8 = 48 ways; an English book and a Amharic book, in 6 · 10 = 60 ways; a Ge’ez book and a Amharic
book, in 8 · 10 = 80 ways. Thus there are 48 + 60 + 80 = 188 ways of selecting 2 books in 2 languages.
Example 1.8 — Binary Strings. How many different bit strings of length seven are there?
Solution. Each of the seven bits can be chosen in two ways, because each bit is either 0 or 1. Therefore,
the product rule shows there are a total of 27 = 128 different bit strings of length seven.
Example 1.9 — Functions. How many functions are there from a set with m elements to a set with n
elements?
Solution. A function corresponds to a choice of one of the n elements in the codomain for each of the m
elements in the domain. Hence, by the product rule there are n · n · · · n = nm functions from a set with
m elements to one with n elements.
Example 1.10 — One-One Functions. How many one-to-one functions are there from a set with m
elements to one with n elements?
Solution. First note that when m > n there are no one-to-one functions from a set with m elements to a
set with n elements.
4 Chapter 1. Elementary counting principles
Now let m ≤ n. Suppose the elements in the domain are a 1 , a 2 , . . . , am . There are n ways to choose the
value of the function at a 1 . Because the function is one-to-one, the value of the function at a 2 can be
picked in n − 1 ways (because the value used for a 1 cannot be used again). In general, the value of the
function at ak can be chosen in n −k + 1 ways. By the product rule, there are n(n − 1)(n − 2) · · · (n −m + 1)
one-to-one functions from a set with m elements to one with n elements.
Example 1.11 — Subsets. How many different subsets does the set A = {1, 2, 3} have?
Solution. Let S be an arbitrary subset of A. Tree diagrams can be used to handle problems of this nature
(See Figure 1.3). There are 23 = 8 subsets of A.
1∈S
Y N
2∈S 2∈S
www.albohessab.weebly.com
Y N Y N
Y N Y N Y N Y N
{1, 2, 3} {1, 2} {1, 3} {1} {2, 3} {2} {3} {}
Figure 1.3
Solution. There are two choices (0 or 1) for each element in the string. Hence, there are 2n possible
strings.
Solution. Each element in the given n-element set can either be included or not included in a subset.
Hence, there are
2 × 2 × 2 × · · · × 2 = 2n
| {z }
n
www.albohessab.weebly.com
where
1, ai ∈ S
(
bi =
0, otherwise.
Each subset is represented uniquely as a string of 0 and 1 of length n. Also, each string corresponds to
only one subset. Then, we can conclude that the number of subsets equal the number of bit strings of
length n.
This method of representing sets not only makes the problem of counting subsets simple but also makes
computing the combination of sets easy.
Example 1.14 The bit string for the set {1, 3, 5, 7, 9} (with universal set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) is
1010101010. What is the bit string for the complement of this set?
Solution. The bit string for the complement of this set is obtained by replacing 0s with 1s and vice versa.
This yields the string 0101010101, which corresponds to the set {2, 4, 6, 8, 10}.
To obtain the bit string for the union and intersection of two sets we perform bitwise Boolean operations
on the bit strings representing the two sets. The bit in the ith position of the bit string of the union is 1 if
either of the bits in the ith position in the two strings is 1 (or both are 1). The bit in the ith position of
the bit string of the intersection is 1 when the bits in the corresponding position in the two strings are
both 1, and is 0 when either of the two bits is 0 (or both are).
Example 1.15 Given the universal set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, the bit strings for the sets {1, 2, 3, 4, 5}
and {1, 3, 5, 7, 9} are 1111100000 and 1010101010, respectively. Use bit strings to find the union and
intersection of these sets.
1.2.1 Permutations
A permutation of a set of distinct objects is an ordered arrangement of these objects. For example, there
are 6 permutations of the letters from the set S = {a, b, c}:
Permutations reflect selections for which an ordering is important. For example, 12 and 21 are different
permutations of S = {1, 2}.
Example 1.16 How many ways are there to put 8 children in a line to get ice cream?
Solution. Note that the ordering of the children is important, especially to them! There are 8 children
www.albohessab.weebly.com
from which to pick the child who is first. Then there are 7 children left from which to pick the second
child. Then there are 6 left, and so on. Therefore, there are
8 · 7 · 6 · 5 · 4 · 3 · 2 · 1 = 8! = 40320
Example 1.17 How many different license plates consisting of 6 distinct digits (0 to 9) are possible?
Solution. Any digit can be the first. Then there are 9 digits left from which to choose the second. Then
there are 8 choices left for the third, and so on. Hence, there are
10 · 9 · 8 · 7 · 6 · 5 = 151200
Definition 1.2.1 An r -permutations of n elements is the number of ways to arrange r objects chosen
from n distinct objects. When r = n, an r -permutation is simply called a permutation.
Example 1.18 Let S = {a, b, c}. The 2-permutations of S are the ordered arrangements
Consequently, there are six 2-permutations of this set with three elements. There are always six 2-
permutations of a set with three distinct elements.
• There are three ways to choose the first element of the arrangement.
• There are two ways to choose the second element of the arrangement.
Hence, by the product rule, we see that P(3, 2) = 3 · 2 = 6.
1.2 Permutations and combinations 7
Example 1.19 Let A = {a, b, c, d}. All the 3-permutations of A are shown below:
n!
P(n, r ) = n(n − 1)(n − 2) · · · (n − r + 1) = (1.1)
(n − r )!
Proof. The first element of the permutation can be chosen in n ways because there are n elements in
the set. There are n − 1 ways to choose the second element of the permutation, because there are n − 1
elements left in the set after using the element picked for the first position. Similarly, there are n − 2
www.albohessab.weebly.com
ways to choose the third element, and so on, until there are exactly n − (r − 1) = n − r + 1 ways to choose
the r th element. Consequently, by the product rule, there are
n(n − 1)(n − 2) · · · (n − r + 1)
Corollary 1.2.2 There are n! = n(n − 1)(n − 2) · · · 2 · 1 permutations of n (distinct) elements, i.e.
P(n, n) = n!.
Solution. We have
8! 8!
1. P(8, 5) = = = 8 · 7 · 6 · 5 · 4 = 6720
(8 − 5)! 3!
0! 0!
2. P(0, 0) = = =1
(0 − 0)! 0!
6! 6!
3. P(6, 2) = = = 6 · 5 = 30
(6 − 2)! 4!
Example 1.22 Yirgalem has 10 different mathematics books and 8 different chemistry books. In how
many ways can she
1. put all 18 books on a shelf?
2. put 6 books on a shelf?
3. put half of the math and half of the chemistry books on a shelf, with the math books all to the left
of the chemistry books?
www.albohessab.weebly.com
Example 1.23 How many permutations of the letters ABCDEFGH contain the string ABC?
Solution. Because the letters ABC must occur as a block, we can find the answer by finding the number
of permutations of six objects, namely, the block ABC and the individual letters D, E, F, G, and H. Because
these six objects can occur in any order, there are 6! = 720 permutations of the letters ABCDEFGH in
which ABC occurs as a block.
Anagrams
An anagram of a word is another word (or sometimes many words) which is built up from the letters of
the original, using each letter exactly once. For example an anagram of ‘retinas’ can be ‘nastier’, ‘retains’,
or ‘stainer’. Even ‘sainter’ is a meaningful anagram (means trustworthy). One can even form anagrams
using multiple words, like ‘tin ears’ or ‘in tears’.
We are interested in the number of anagrams a word can have. Of course, the number of all meaningful
anagrams would be very hard to find, because some expressions can be meaningful to some, and not to
others. For example, Oxford English Dictionary only contains the following anagrams of ‘east’: ‘a set’,
‘east’, ‘eats’, ‘sate’ (i.e. satisfy), ‘seat’, ‘teas’. Nevertheless, there is meaning given to all possible anagrams
of ‘east’ in Ross Eckler’s Making the Alphabet Dance.1
Example 1.24 In any case, how many possible anagrams are there for the word ‘east’?
Solution. Let us build them up: for the first letter we have 4 choices, then we have only 3 choices for the
second letter, we are left only with two choices for the third letter, and the not chosen letter will be the
forth. That is, altogether there are 4 · 3 · 2 · 1 = 4! = 24-many anagrams. This is exactly the number of
permutations of the four letter ‘a’, ‘e’, ‘s’ and ‘t’.
1 Ross Eckler, Making the Alphabet Dance, St Martins Pr (July 1997)
1.2 Permutations and combinations 9
Circular Permutations
The permutations that we have just considered are more properly called linear permutations. We think
of the objects as being arranged in a line (row). If instead of arranging objects in a line, we arrange them
in a circle, is the number of permutations the same? No!
Think of it this way: Suppose 6 children are marching in a circle. In how many different ways can they
form their circle?
Since the children are moving, what matters are their positions relative to each other and not to their
environment. Thus it is natural to regard two circular permutations as being the same provided one can
be brought to the other by a rotation, that is, by a circular shift. There are 6 linear permutations for each
circular permutation. For example, the circular permutation
1
2 6
www.albohessab.weebly.com
3 5
Figure 1.4
Proof. Each circular permutation corresponds to n linear permutations depending upon from where
we start. Since there are n! linear permutations, it follows that there are n!/n = (n − 1)! circular
permutations.
Example 1.25 Find the number of ways in which 8 men and 4 women stand in a circle such that no
two women are next to each other.
Solution. According to circular arrangement 8 men can stand in a circle in (8 − 1)! = 7! ways. It indicates
that there are 8 locations available in the circle for 4 women.
So, first women can stand in 8 ways; second women can stand in 7 ways; third women can stand in 6
ways whereas fourth women can stand in 5 ways. Therefore, the total number of ways in which no two
women are next to each other
7! · (8 · 7 · 6 · 5) = 7! · P(8, 4) = 8467200.
10 Chapter 1. Elementary counting principles
1.2.2 Combinations
Although some counting problems contain an ordering requirement, there are also situations in which
order is not important. For example, the elements in a set need not be listed in any particular or-
der.
Definition 1.2.2 Let S be a set of n distinct objects. For 0 ≤ r ≤ n, an r -combination of a set S is an
unordered selection of r of the n objects of S.
What is the difference between a permutation and a combination of a set of objects? A permutation is an
arrangement of certain objects and thus the ordering of objects is important, whereas a combination is
www.albohessab.weebly.com
just a set of objects and thus the ordering of objects is insignificant. The following theorem provides us
with a means to relate the numbers P(n, r ) and C(n, r ).
Theorem 1.2.4 For 0 ≤ r ≤ n,
n
P(n, r ) = r !
r
and hence
n n!
= (1.2)
r r !(n − r )!
Proof. Let S be an n-element set. Each r -permutation of S can be obtained in the following way:
1. Choose r elements from S.
2. Arrange the chosen r elements in some order.
The number of ways to choose r elements from S is by definition
n
r
The number of ways to arrange r elements is
P(r , r ) = r !
By Multiplication Principle we have
n
P(n, r ) = r !
r
The value of n is 1, since an n-element
n
set has exactly one n-element subset, namely itself. It may look
a bit more tricky to find that 0 = 1, but it is just as easy to explain: Every set has a single 0-element
n
subset, namely the empty set. This is true even for the empty set, so that 00 = 1.
www.albohessab.weebly.com
r n −r
Proof. Deciding which r objects to select from a set of n objects amounts to exactly the same thing as
deciding which n − r objects not to select. Hence the number of ways of choosing r objects from n is the
same as the number of ways of choosing n − r objects from n.
and
n n! n!
= =
n −r (n − r )!(n − (n − r ))! (n − r )!r !
Sometimes, we will be forced to include or exclude particular items when making a combination. This
will reduce the number of items in our selection, and also the number of items we can select. This is
illustrated in the following example.
Example 1.27 In how many ways can 11 players be chosen from a group of 13 players if
1. the players are selected at random?
2. a particular player must be included?
3. a certain player must be excluded?
13 13! 13 · 12
= = = 78 ways
11 11!(13 − 11)! 2
12 Chapter 1. Elementary counting principles
2. If one particular player is always to be included, we need to select 10 more out of the remaining
12. This can be accomplished in:
12 12! 12 · 11
= = = 66 ways
10 10!(12 − 10)! 2
3. If one player should be excluded from the team, we need a selection of 11 players from the
remaining group of 12. Thus, the required number of such combinations is:
12 12!
= = 12 ways
11 11!(12 − 11)!
When presented with multiple groups of items from which we are required to make a selection, we will
multiply the separate cases together.
Example 1.28 In how many ways can we form a committee of three professors and two students from
www.albohessab.weebly.com
5 5!
= = 10
3 2!3!
8 8!
= = 28
2 2!6!
ways. Since the committee can be constituted in two steps: select the professors, select the students, by
product rule, the committee can be formed in
10 · 28 = 280 ways.
Questions containing the phrase “at least/at most” will require as to add all the possible cases together.
Sometimes it is helpful to know the shortcuts (see complement principle).
Example 1.29 How many five-person committees can be formed from a group of six men and five
women consists of
i) at least one man
ii) at most one man.
Solution. i) We have 11 persons in total. Therefore the total number of five-person committee is
11 11!
= = 462.
5 5!6!
1.2 Permutations and combinations 13
5
= 1.
5
But the number of committees with at least one man is equal to the total number of five-person
committees minus the number of five-person committees not containing any man,
462 − 1 = 461.
ii) The number of five-person committees with at most one man is five-person committees with one
man or five-person committees with no man. Thus, the number of five-person committees with
no man (five-person committees consisting entirely of women) is
5
=1
5
www.albohessab.weebly.com
6 5
= 6 · 5 = 30
1 4
1 + 30 = 31.
Example 1.30 How many committees of four persons with a given chair person can be selected from
10 persons?
Solution. The chairman can be selected in 10 ways since he can be any of the 10 persons. The remaining
3 persons are to be selected from the remaining 9 persons. This can be done in 93 ways. So, by product
9 9!
10 · = 10 = 840.
3 3!6!
Example 1.31 A woman has 11 close friends and she wants to invite 5 of them to dinner. In how many
ways can she invite them if
i) There is no restriction
ii) Two particular persons will not attend separately
iii) Two particular persons will not attend together
11 11!
= = 462 ways.
5 5!6!
14 Chapter 1. Elementary counting principles
ii) As per condition, two particular persons will not attend separately. So, either they both should be
invited or they both should not be invited.
If they both are invited, then three more persons should be invited out of the nine persons. This
task can be done in
9 9!
= = 84 ways.
3 3!6!
If they both are not invited, the five persons should be invited out of the nine remaining friends.
This task can be done in
9 9!
= = 126 ways.
5 5!4!
By sum rule, the total in which the invitation can be sent is 84 + 126 = 210 ways.
iii) Since, two particular persons can not be invited together, either one of them should be invited or
none of them should be invited.
www.albohessab.weebly.com
If one of them is invited, then four more friends are to be invited out of nine friends. This task of
inviting can be performed in
9 9!
= ways.
4 4!5!
9 9!
= = 126 ways.
5 5!4!
Thus, by addition principle, the total number of ways in which she can invite her friends is
126 + 126 + 126 = 378 ways.
Example 1.32 A box contains six white balls and five red balls. In how many ways can four balls be
drawn from the box if
i) They can be of any color
ii) Two balls should be white and two red
iii) All the balls should be of the same color
Solution. i) Since there is no restriction on the selection, the number of ways in which 4 balls can be
drawn out of 11 balls is
11 11!
= = 330.
4 4!7!
1.2 Permutations and combinations 15
ii) Two white balls are to be drawn out of six balls. This task can be performed in
6 6!
= = 15 ways.
2 2!4!
Similarly, two red balls are to be drawn out of five red balls. This task can be done in
5 5!
= = 10 ways.
2 2!3!
By product rule, the task of drawing two white balls and two red balls can be done in 15 · 10 = 150
ways.
iii) Since the balls should be of the same color, they all can be white color or they all can be red.
If all the four balls drawn are to be white, we have to choose four balls out of six white balls. this
task can be done in
6 6!
= = 15 ways.
4 4!2!
www.albohessab.weebly.com
If all the four balls drawn are to be red, we have to choose four balls out of five red balls. this task
can be done in
5 5!
= = 5 ways.
4 4!1!
Therefore, by sum rule, the number of ways in which all the four balls are of the same color is
15 + 5 = 20.
The following theorem is known as Pascal’s Identity which gives a useful identity for efficiently computing
binomial coefficients.
Theorem 1.2.6 — Pascal’s Identity. For all positive integers k, n with k ≤ n,
n−1 n−1
n
= + (1.4)
k k −1 k
While we can prove this equation algebraically using definitions of binomial coefficients, proving the
fact by describing the process of choosing k-subsets reveals interesting insights.
Combinatorial Proof. Note that the right side of the identity nk is counting how many ways can we get
When X is not in the subset, we need to choose all the k elements in the subset from the n − 1 objects
that are not X . This can be done in n−1
k ways.
We conclude that the numbers of ways to get a k-subset from the n-set, which we know is nk , is also the
number n−1k−1 + k .
n−1
16 Chapter 1. Elementary counting principles
Algebraic
Proof.
n−1 n−1 (n − 1)! (n − 1)!
+ = +
k −1 k (k − 1)! · (n − 1 − (k − 1))! k! · (n − 1 − k)!
(n − 1)! (n − 1)!
= +
(k − 1)! · (n − k)! k! · (n − k − 1)!
(n − 1)! · k + (n − 1)! · (n − k)
=
k! · (n − k)!
(n − 1)! · (k + n − k)
=
k! · (n − k)!
(n − 1)! · n
=
k! · (n − k)!
n!
=
k! · (n − k)!
n
= .
k
www.albohessab.weebly.com
Pascal’s Triangle
To study various properties of binomial coefficients, the following picture is very useful. We arrange
all binomial coefficients into a triangular scheme: in the “zeroth" row we put 00 ; in the first row, we
1 1 2 2 2
put 0 and 1 ; in the second row, 0 , 1 , and 2 ; etc. In general, the nth row contains the numbers
0 , 1 , . . . , n . We shift these rows so that their midpoints match; this way we get a pyramidlike
n n n
scheme, called Pascal’s Triangle (named after the French mathematician and philosopher Blaise Pascal,
1623–1662). The figure below shows only a finite piece of Pascal’s Triangle.
0
0
1 1
0 1
2 2 2
0 1 2
3 3 3 3
0 1 2 3
4 4 4 4 4
0 1 2 3 4
5 5 5 5 5 5
0 1 2 3 4 5
6 6 6 6 6 6 6
0 1 2 3 4 5 6
We can replace each binomial coefficient by its numerical value to get another version of Pascal’s Triangle
(going a little further down, to the eighth row):
Permutations with Repetition
The number of r -permutations of a set with n elements when repetition is allowed is given in Theorem
1.2.7.
1.2 Permutations and combinations 17
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
Theorem 1.2.7 The number of r -permutations of a set of n objects with repetition allowed is nr .
www.albohessab.weebly.com
Proof. There are n ways to select an element of the set for each of the r positions in the r -permutation
when repetition is allowed, because for each choice all n objects are available. Hence, by the product
rule there are nr r -permutations when repetition is allowed.
Example 1.33 How many strings of length r can be formed from the uppercase letters of the English
alphabet?
Solution. By the product rule, because there are 26 uppercase English letters, and because each letter
can be used repeatedly, we see that there are 26r strings of uppercase English letters of length r .
denote the number of permutations of n objects of which n 1 are alike, n 2 are alike,. . . , nk are alike. The
general formula follows:
where n 1 + n 2 + · · · + nk = n.
Proof. Each permutation is a sequence of all n elements of the multiset. There are then nn1 to choose
where the n 1 copies of element a 1 are placed. This leaves n − n 1 positions for the n 2 copies of element a 2 ,
so these can be placed in n−nn2
1
ways. Continuing until all of the elements are positioned, we see that
18 Chapter 1. Elementary counting principles
there are
n n − n1 n − n1 − n2 n − n 1 − · · · − nk−1
...
n1 n2 n3 nk
n! (n − n 1 )! (n − n 1 − · · · − nk −1 )!
= ...
n 1 !(n − n 1 )! n 2 !(n − n 1 − n 2 )! nk !(0!)
n!
=
n 1 !n 2 ! . . . nk !
n
Notation 1.4. The number is called a multinomial coefficient.
n 1 , n 2 , . . . , nk
Example 1.34 In how many ways can the letters of the word MISSISSIPPI be arranged?
Solution. This is an example of a permutation of a set with repeated elements. There are 11! permutations
of the 11 letters of MISSISSIPPI, but there is much duplication. We need to divide by the number of
permutations of the four I’s, the four S’s, the two P’s, and the one M. Thus, the number of different
arrangements of the letters is
www.albohessab.weebly.com
11 11!
= = 34, 650
4, 4, 2, 1 4!4!2!1!
Example 1.35 In how many ways can the letters of the word INJIBARA be arranged?
Solution. There are 8 letters in the word INJIBARA, with 2 I’s, 1 N, 1 B, 2 A’s and 1 R. Hence, the number
of ways to arrange the word INJIBARA is
8 8!
= = 10080
2, 1, 1, 2, 1 2!1!1!2!1!
Combinations with Repetition
The symbol nk , read as “n multichoose k”, denotes the number of the ways to select k objects from
a set of n elements, where order is not important, but repetition is allowed. For instance, there are 20
possible multisubsets of size 3 that can be created from {1, 2, 3, 4} are illustrated in Table 1.3. By contrast
k counts the same situation where repetition is not allowed. The four possible 3-subsets of {1, 2, 3, 4}
n
4 4
= 20
3 3
{1, 1, 1} {1, 2, 3} {2, 2, 2} {2, 4, 4} {1, 2, 3}
{1, 1, 2} {1, 2, 4} {2, 2, 3} {3, 3, 3} {1, 2, 4}
{1, 1, 3} {1, 3, 3} {2, 2, 4} {3, 3, 4} {1, 3, 4}
{1, 1, 4} {1, 3, 4} {2, 3, 3} {3, 4, 4} {2, 3, 4}
{1, 2, 2} {1, 4, 4} {2, 3, 4} {4, 4, 4}
Alternately, n
k counts the nonnegative integer solutions to
x 1 + x 2 + · · · + x n = k.
1.2 Permutations and combinations 19
Moreover, nk counts ways that we can distribute k identical pieces of kandy to n hungry nerds. Nerds
may receive any number of kandies, including possibly zero. Here x i denotes the number of kandies
given to nerd i. (We apologize for the intentional misspelling, but it does help you remember which is n
and which is k.)
Conveniently, nk can be expressed in terms of binomial coefficients.
x1 + x2 + x3 = 5
www.albohessab.weebly.com
Solution. To count the number of solutions, we note that a solution corresponds to a way of distributing
5 ‘kandies’ to three nerds. We represent the 5 kandies by 5 ‘stars’ and consider 2 ‘bars’ in between stars
to separate the stars in to 3 groups. For example, the distribution 3, 0, 2 is represented by
? ? ?|| ? ?
Note that if two bars appears next to each other the person gets zero kandy. There are a total of 5 + 3 − 1
positions, of which 5 are stars and 2 are bars. Thus, the we need to choose the 5 places where to put the
stars, then the rest of the places will be occupied by the bars. The number of ways this can be done is
5+3−1 7!
= = 21.
5 5!2!
x 1 + x 2 + x 3 + x 4 = 20,
in which
x 1 ≥ 3, x 2 ≥ 1, x 3 ≥ 0 and x 4 ≥ 5?
y1 = x 1 − 3, y2 = x 2 − 1, y3 = x 3 , y4 = x 4 − 5,
y1 + y2 + y3 + y4 = 11.
20 Chapter 1. Elementary counting principles
The lower bounds on the x i ’s are satisfied if and only if the yi ’s are nonnegative. The number of
nonnegative integer solutions of the new equation, and hence the number of nonnegative solutions of
the original equation, is
11 + 4 − 1 14
= = 364.
11 11
R The following table is useful to select formula for choosing r elements from n elements:
www.albohessab.weebly.com
Repetition is allowed nr
r
|A ∪ B| = |A| + |B| − |A ∩ B|
Proof. Our approach is motivated by the Venn diagram reflecting this general situation. See Figure 1.5
which shows two sets, A and B, and their intersection.
A∩B
A B
The sum |A| + |B| counts all the elements of A ∪ B, but the elements of A ∩ B are counted twice and
therefore must be removed.
1.3 The inclusion-exclusion principles 21
The name inclusion-exclusion comes from the idea that the principle is based on over-generous inclusion,
followed by compensating exclusion.
R The Addition Principle is simply the special case of the Basic Inclusion Exclusion Principle in which
|A ∩ B| = 0.
Definition 1.3.1 The floor of a real number x is the largest integer less than or equal to x. It is denoted
by bxc.
jn k
R The number of positive integers less than or equal to n that are divisible by k equals .
k
Example 1.39 How many integers in the range 1 to 1000 (inclusive) are divisible by 2 or by 5?
www.albohessab.weebly.com
Solution. Let
Therefore there are 600 integers in the range 1 to 1000 that are divisible by either 2 or 5.
Let us now present the complement principle that is useful in solving Example 1.40.
Theorem 1.3.2 — Complement Principle. Let U be a finite universal set containing A, then
Example 1.40 How many positive integers not exceeding 100 are divisible by neither 2 nor 3?
Solution. Let A denote the positive integers not exceeding 100 that are divisible by 2 and B denote the
positive integers not exceeding 100 that are divisible by 3. Thus,
Hence, the number of positive integers not exceeding 100 that are divisible by 2 or 3 is
Therefore, by complement principle, the number of positive integers not exceeding 100 that are not
divisible by 2 and 3 are
100 − 67 = 33.
The inclusion-exclusion principle can be extended to the problem of counting the number of elements in
the union of three sets.
Theorem 1.3.3 Given finite sets A, B and C, then
|A ∪ B ∪ C | = |A| + |B| + |C | − |A ∩ B| − |A ∩ C | − |B ∩ C | + |A ∩ B ∩ C |
www.albohessab.weebly.com
Example 1.41 How many integers between 1 and 1000 are divisible by at least one of 7, 9, and 11?
Solution. Let
• S denote the set of integers between 1 and 1000 divisible by 7,
• N denote the set of integers between 1 and 1000 divisible by 9,
• E denote the set of integers between 1 and 1000 divisible by 11.
We need to count the number of integers in S ∪ N ∪ E. By the principle of inclusion-exclusion,
|S ∪ N ∪ E| = |S | + |N | + |E| − |S ∩ N | − |S ∩ E| − |N ∩ E| + |S ∩ N ∩ E|
1000 1000 1000 1000 1000 1000 1000
= + + − − − +
7 9 11 63 77 99 693
= 142 + 111 + 90 − 15 − 12 − 10 + 1 = 307
Example 1.42 How many students are in a calculus class if 14 are math majors, 22 are computer science
majors, 15 are engineering majors, and 13 are chemistry majors, if 5 students are double majoring in
math and computer science, 3 students are double majoring in chemistry and engineering, 10 are double
majoring in computer science and engineering, 4 are double majoring in chemistry and computer science,
none are double majoring in math and engineering and none are double majoring in math and chemistry,
and no student has more than two majors?
1.4 The pigeonhole principle 23
Solution. Let A1 denote the math majors, A2 denote the computer science majors, A3 denote the engi-
neering majors, and A4 the chemistry majors. Then the information given is
|A1 | = 14, |A2 | = 22, |A3 | = 15, |A4 | = 13,
|A1 ∩ A2 | = 5, |A1 ∩ A3 | = 0, |A1 ∩ A4 | = 0, |A2 ∩ A3 | = 10, |A2 ∩ A4 | = 4, |A3 ∩ A4 | = 3,
|A1 ∩ A2 ∩ A3 | = 0, |A1 ∩ A2 ∩ A4 | = 0, |A2 ∩ A3 ∩ A4 | = 0,
and
|A1 ∩ A2 ∩ A3 ∩ A4 | = 0.
So, by inclusion-exclusion, the number of students in the class is
14 + 22 + 15 + 13 − 5 − 10 − 4 − 3 = 42.
www.albohessab.weebly.com
simple proposition:
Proposition 1.4.1 — Pigeonhole Principle. If n pigeonholes shelter n + 1 or more pigeons, then there is
at least one pigeonholes containing two or more pigeons.
Example 1.43 To ensure that a class includes at least 2 students whose last names begin with the
same letter of the (English) alphabet, the class should have at least 27 students. (Here the letters are the
pigeonholes.)
Example 1.44 Show that among 53 students there are two born on the same week.
Example 1.45 Suppose that a test corrected out of 10, is given integer values from 0 to 10. What is the
minimum number of students to guarantee that two get the same mark?
Example 1.46 Suppose a department contains 13 professors, then two of the professors (pigeons) were
born in the same month (pigeonholes).
Example 1.47 Suppose there are many red socks, many white socks, and many blue socks in a box.
What is the least number of socks that one should grab from the box (without looking at the contents) to
be sure of getting a matching pair? If each color is considered as a pigeonhole, then n = 3. Therefore, if
one grabs n + 1 = 4 pigeons (socks), at least 2 of them will share a color.
Definition 1.4.1 The ceiling of a real number x is the smallest integer greater than or equal to x. It is
denoted by dxe.
Proof. We will use a proof by contraposition. Suppose that none of the boxes contains more than
dN /ke − 1 objects. Then, the total number of objects is at most
N N
k −1 <k +1 −1 =N
k k
24 Chapter 1. Elementary counting principles
where the inequality dN /ke < (N /k) + 1 has been used. This is a contradiction because there are a total
of N objects.
A common type of problem asks for the minimum number of objects such that at least r of these objects
must be in one of k boxes when these objects are distributed among the boxes.
When we have N objects, the generalized pigeonhole principle tells us there must be at least r objects in
one of the boxes as long as dN /ke ≥ r . The smallest integer N with N /k > r − 1, namely, N = k(r − 1) + 1,
is the smallest integer satisfying the inequality dN /ke ≥ r . Could a smaller value of N suffice? The
answer is no, because if we had k(r − 1) objects, we could put r − 1 of them in each of the k boxes and
no box would have at least r objects.
When thinking about problems of this type, it is useful to consider how you can avoid having at least r
objects in one of the boxes as you add successive objects. To avoid adding a r th object to any box, you
eventually end up with r − 1 objects in each box. There is no way to add the next object without putting
an r th object in that box.
Example 1.49 Find the minimum number of students in a class to be sure that three of them are born
www.albohessab.weebly.com
in the same month.
Solution. The minimum number of students needed to ensure that at least three of them are born
in the same month is the smallest integer N such that dN /12e = 3. The smallest such integer is
N = 12 · 2 + 1 = 25.
Example 1.50 What is the minimum number of students required in a discrete mathematics class to be
sure that at least six will receive the same grade, if there are five possible grades, A, B, C, D, and F ?
Solution. The minimum number of students needed to ensure that at least six students receive the same
grade is the smallest integer N such that dN /5e = 6. The smallest such integer is N = 5 · 5 + 1 = 26. If
you have only 25 students, it is possible for there to be five who have received each grade so that no six
students have received the same grade. Thus, 26 is the minimum number of students needed to ensure
that at least six students will receive the same grade.
this strange name: it comes from a very important formula in algebra involving them, which we discuss
next.
The issue is to compute powers of the simple algebraic expression (x + y). We start with small examples:
(x + y)1 = x + y
(x + y)2 = x 2 + 2xy + y 2 ,
(x + y)3 = (x + y) · (x + y)2 = (x + y) · (x 2 + 2xy + y 2 )
= x 3 + 3x 2y + 3xy 2 + y 3 ,
These coefficients are familiar! The coefficients arising in these expressions are exactly the numbers
occurring in Pascal’s triangle. Indeed, the coefficients of (x + y) are 1 = 0 , 4 = 41 , 6 = 42 , 4 = 43 , 1 =
4 4
4
4 . Let us make this observation precise. We illustrate the argument for the next value of n, namely
n = 5, but it works in general. Think of expanding
so that we get rid of all parentheses. We get each term in the expansion by selecting one of the two
terms in each factor, and multiplying them. If we choose x, say, 2 times, then we must choose y 3 times,
and so we get x 2y 3 . How many times do we get this same term? Clearly, as many times as the number of
ways to select the three factors that supply y (the
remaining factors supply x). Thus we have to choose
three factors out of 5, which can be done in 53 ways. Hence the expansion of (x + y)5 looks like this:
5 5 5 4 5 3 2 5 2 3 5 5 5
5 4
(x + y) = x + x y+ x y + x y + xy + y
0 1 2 3 4 5
www.albohessab.weebly.com
We can apply this argument in general to obtain the Binomial Theorem.
Theorem 1.5.1 — Binomial Theorem. Let x, y be real numbers. Then for every nonnegative integer n,
n
n n
n n n−1 n n−2 2 n n−1 n n Õ n n−k k
(x + y) = x + x y+ x y +···+ xy + y = x y .
0 1 2 n−1 n k
k =0
Each term of the expansion of the product results from choosing either x or y from one of these factors.
If x is chosen n − k times and y is chosen k times, then the resulting product is x n−k y k . Clearly, the
number of such terms is C(n, k), i.e., out of the n factors, we choose the element y from i of them, while
we take x in the remaining n − k.
This important identity was discovered by the famous Persian poet and mathematician Omar Khayyam.
Its name comes from the Greek word binome for an expression consisting of two terms, in this case, x +y.
The appearance of the numbers nk in this theorem is the source of their name: binomial coefficients.
Induction proof. Note first, that the Binomial theorem holds for n = 0 and n = 1, as well: (x + y)0 = 1 =
0 0 0 1 1 1 0 1 0 1
0 x y , (x + y) = x + y = 0 x y + 1 x y . Now, we can prove the theorem by induction on n. Assume
that the statement holds for n − 1, that is,
n−1
n−1
Õ
n−1
(x + y) = x n−1−k y k .
k
k=0
26 Chapter 1. Elementary counting principles
This is the induction hypothesis. Now, compute (x + y)n using the same method as before, and use the
induction hypothesis for expanding (x + y)n−1 :
n−1
n−1
!
Õ
n n−1 n−1−k k
(x + y) = (x + y) · (x + y) = x y · (x + y)
k
k =0
n−1 n−1
n − 1 n−1−k k n − 1 n−1−k k
Õ Õ
= x y ·x + x y ·y
k k
k =0 k=0
n−1 n−1
n − 1 n−k k Õ n − 1 n−1−k k+1
(1.6)
Õ
= x y + x y
k k
k=0 k=0
n−1 n−2
n − 1 n−k k Õ n − 1 n−1−k k+1
(1.7)
Õ
n
=x + x y + x y + yn
k k
k=1 k =0
n−1 n−1
n − 1 n−k k n − 1 n−k k
Õ Õ
n
=x + x y + x y + yn
k k −1
www.albohessab.weebly.com
k=1 k=1
n−1
Õ n−1 n−1
= xn + + x n−k y k + y n (1.8)
k k −1
k=1
n−1 n
n
Õ n n−k k n
Õ n n−k k
=x + x y +y = x y .
k k
k=1 k=0
Here, we have separated x n and y n from the sums in (1.6), then “re-indexed” the second sum in (1.7) to
find the coefficient of the common terms x n−k y k (for k = 1, 2, . . . , n − 1) of the two sums. Finally, in (1.8)
we used the Pascal’s identity (Theorem 1.2.6).
The Binomial theorem can be used to calculate several nth powers. For example, choosing y = 1, every
power of y is 1, as well, thus
n n−2 2
(x + 1) = x + nx
n n
·1+
n−1
x · 1 + · · · + nx · 1n−1 + 1n
2
n
n n−2 n k
+ · · · + nx + 1 =
Õ
n n−1
= x + nx + x x .
2 k
k=0
1.5 The Binomial Theorem 27
Choosing y = −1 yields
n n−2
(x − 1) = x + nx
n n n−1
· (−1) + x · (−1)2 + · · · + nx · (−1)n−1 + (−1)n
2
n n−2
= x n − nx n−1 + x − · · · + (−1)n−1nx + (−1)n
2
n
www.albohessab.weebly.com
k n n−k
Õ
= (−1) x .
k
k=0
R
• The calculation of the coefficients is simplified by using the symmetry of the binomial
coefficients, i.e.
n n
=
r n −r
Example 1.52 Find the 10th term in the expansion of (3x 2 − 2y)13 .
13 13! 4
T10 = (3x 2 )13−9 (−2y)9 = (3) (−2)9x 8y 9
9 9!4!
There are times when we are interested not in the full expansion of a power of a binomial, but just the
coefficient on one of the terms.
Example 1.53 What is the coefficient of x 3y 7 in the expansion of (x + y)10 ?
Solution. First, note that this expression equals (2x + (−3y))13 . By the binomial theorem, we have
13
13 13
(2x)13−k (−3y)k
Õ
(2x + (−3y)) =
k
k=0
13 5
2 (−3)8
8
We can prove some useful identities using the binomial theorem, as Corollaries 1.5.2, 1.5.3, and 1.5.4
demonstrate.
Corollary 1.5.2 Let n be a nonnegative integer. Then
www.albohessab.weebly.com
n
n
= 2n
Õ
k
k =0
There is also a nice combinatorial proof of Corollary 1.5.2, which we now present.
Proof. A set with n elements has a total of 2n different subsets. Each subset has zero elements, one
element, two elements, . . . , or n elements in it. There are n
0 subsets with zero elements, n
1 subsets
with one element, n2 subsets with two elements, . . . , and nn subsets with n elements. Therefore,
n
Õ n
k
k =0
counts the total number of subsets of a set with n elements. By equating the two formulas we have for
the number of subsets of a set with n elements, we see that
n
n
= 2n
Õ
k
k =0
1.5 The Binomial Theorem 29
Proof. When we use the binomial theorem with x = −1 and y = 1, we see that
n n
n n−k k n
0 = (1 + (−1)) = 1 (−1) =
Õ Õ
n n k
(−1)
k k
k =0 k=0
www.albohessab.weebly.com
Moreover, Corollary 1.5.2 and Corollary 1.5.3 implies that, for n even,
n n n n n n n n
+ + +···+ =2 n−1
= + + +···+
0 2 4 n 1 3 5 n−1
For n odd,
n n n n n n n n
+ + +···+ = 2n−1 = + + +···+
1 3 5 n 0 2 4 n
Proof. When we use the binomial theorem with x = 1 and y = 2, we see that
n n
n n−k k Õ k n
3 = (1 + 2) = 1 2 = 2
Õ
n n
k k
k=0 k=0
3 3 3
3 3 2
(a + b + c) = a + a b+ ab 2
3, 0, 0 2, 1, 0 1, 2, 0
3 3 3
3 2
+ b + ac+ abc
0, 3, 0 2, 0, 1 1, 1, 1
3 3 3 3
2 2 2
+ b c+ ac + bc + c3
0, 2, 1 1, 0, 2 0, 1, 2 0, 0, 3
= a 3 + 3a 2b + 3ab 2 + b 3 + 3a 2c + 6abc + 3b 2c + 3ac 2 + 3bc 2 + c 3 .
Example 1.56 What is the coefficient of x 99y 60z 14 in (2x 3 + y − z 2 )100 ? What about the coefficient of
www.albohessab.weebly.com
x 99y 61z 13 ?
Solution. By the Multinomial Theorem, the expansion of (2x 3 + y − z 2 )100 has terms of the form
100 100
3 k1 k2 2 k3
(2x ) y (−z ) = 2k1 x 3k1 y k2 (−1)k3 z 2k3 .
k1, k2, k3 k1, k2, k3
The x 99y 60z 14 arises when k 1 = 33, k 2 = 60, and k 3 = 7, so it must have coefficient
100
− 233 .
33, 60, 7
For x 99y 61z 13 , the exponent on z is odd, which cannot arise in the expansion of (2x 3 + y − z 2 )100 , so the
coefficient is 0.
Solution. There is one term for each ordered triple (b1 , b2 , b3 ) with b1 + b2 + b3 = 4. One way to count
these triples is to represent them as collections of 2 bars and 4 stars; for instance,
∗| ∗ ∗ ∗ |
4+2
represents the triple (1, 3, 0). The number of such collections is 4 = 15, so there are 15 terms in the
expansion.