Sei sulla pagina 1di 32

1

Discrete Structures I
Draft Lecture Notes By
Omari C.O
Department of Statistics and Actuarial Science
Kimathi University College of Technology
September, 2010
Course Outline
Propositional and predicate calculus, Boolean algebra, introduction to complexity of algo-
rithms, mathematical reasoning, counting, recurrences, relations, and introduction to graphs.
Further Reading Books
1. Discrete Mathematics, 2nd edition, Seymour Lipschutz and Marc Lipson (schaums se-
ries).
2. Data Structures, Seymour Lipschutz, Schaums outlines.
3. Kennrth H. Rosen, Discrete Mathematics and its Applications, 6th edition, 2007, Mc-
Graw Hill.
4. Goodaire and Parmenter, Discrete Mathematics with Graph Theory, 3rd edition 2006,
Prentice Hall.
5. Ralph P. Grimaldi, Discrete and Combinatorial Mathematics, 5th edition, 2004, Addison
Wesley.
6. Kolman, Busby, and Ross, Discrete Mathematical Structures, 5th edition, 2004, Prentice
Hall.
7. D.S. Malik and M.K. Sen, Discrete Mathematics
Course Evaluation
1. Three CATS: 20%
2. Two Assignments: 10%
3. Final Semester Examinations: 70%
Lecture Hours
Wednesday:
Consultation Hours
Tuesday: 9.00am - 1.00pm and Wednesday: 2.00pm - 5.00pm
Chapter 1
Mathematical Logic and
Propositional Calculus
Introduction
Logic is the discipline that considers the methods of reasoning. It provides the rules and tech-
niques for determining whether an argument is valid or not.
In mathematics and computer science, mathematical logic or logic is used to prove results.
Specically, in mathematics we use logic or logical reasoning to prove theorems, and in com-
puter science we use logical or logical reasoning to prove the correctness of programs and also
to prove theorems.
A theorem is a statement that can be shown to be true (under certain conditions). For exam-
ple, in mathematics the following statement is a theorem,
If x is an even integer, then x + 1 is an odd integer.
It can be proved that the above statement under the condition that x is an integer is true.
A proof of a theorem is an argument consisting of a sequence of statements aimed at demon-
strating the truth of the assertion.
Many proofs in mathematics and many algorithms in computer science use logical expres-
sions such as,
If p then q, or If p
1
and p
2
, then q
1
or q
2
.
It is therefore necessary to know the cases in which these expressions are either true or
false: what we refer to as truth values of such expressions.
We also investigate the truth value of quantied statements, which are statements which use
the logical quantier for every and there exists.
Proposition and compound propositions
A proposition (or statement) is a declarative sentence that is either true or false, but not both.
Consider, for example the following sentences:
(i). 4 is an integer
(ii).

5 is an integer
2
3
(iii). x = 2 is a solution of x
2
= 4
(iv). 9 < 6.
(v). Every even integer greater than 4 is a sum of two odd primes.
(vi). Will you pass this unit?
(vii). Enjoy the semester ahead!
Each of these sentences is a declarative sentence, except (v), (vi) and (vii). Sentence (i) is
true, sentence (ii) is not true, sentence (iii) is true,and sentence (iv) is true. Hence, these are
examples of statements.
For sentence (v), so far, no one has been able to prove that this is true. At the same time, no
one has proved that it is false. nevertheless, the sentence above is a statement because it is
either, true or false, but not both. This is known as the Goldbachs conjecture.
Sentences, (vi) and (vii) are not declarative sentences, so these are not statements.
By denition, a statement is a declarative sentence that can be classied as true or false,
but not both. Thus, on e of the values truth or falsity that is assigned to a statement is
called its truth value. We abbreviate truth to T or 1 and falsity to F or 0.
Consider the following inferences:
a < b or a > c
It is not the case that a < b.
Therefore: a > c.
The rst two sentences of the inference are called premises and the last sentence is called
the conclusion. Any simple sentence e.g. a < b is called an atomic sentence. One or more
atomic sentences may be joined to make up compound sentences using connectives.
Compound propositions
Many propositions are composite, that is, composed of sub-propositions and various connec-
tives to be discussed later. Such composite propositions are called compound propositions.
A proposition is said to be primitive if it cannot be broken down into simpler propositions,
that is, if it is not composite.
Example 1.0.1. Consider the following compound propositions.
(a). Roses are Red and Violets are Blue is a compound proposition with sub-propositions
Roses are Red and Violets are Blue.
(b). John is intelligent or studies every night is a compound proposition with sub-propositions
John is intelligent and John studies every night.
(c). The above propositions (i) through to (iv) are all primitive propositions; they cannot be
broken down into simpler propositions.
4
Note: The fundamental property of a compound proposition is that its truth value is com-
pletely determined by the truth value of its sub-propositions together with the way in which
they are connected to form the compound proposition.
Basic Logical Operations
The three basic logical operators are:
1. Negation
2. Conjunction
3. Disjunction
They correspond respectively, to the English words, NOT, AND, and OR.
Chapter 2
Counting Principles
2.1 Basic Counting Principles
There are two main basic counting techniques
1. Addition principle
2. Multiplication principle
2.1.1 Addition Principle
Suppose that we want to nd the number of integers between 4 and 100 that end with 3 or 5.
Let T denote this task. We divide T into the following tasks.
T
1
: Find all integers between 4 and 100 that end with 3.
T
2
: Find all integers between 4 and 100 that end with 5.
Now 13, 23, 33, 43, 53, 63, 73, 83, and 93 are 9 digits between 4 and 100 that end with 3; and
5, 15, 25, 35, 45, 55, 65, 75, 85, and 95 are 10 integers between 4 and 100 that end with 5.
Hence, tasks T
1
and T
2
can be done in 9 and 10 ways, respectively. Both tasks are independent
of each other; i.e., they can be completed in any order because their outcomes do not depend
on each. Therefore, the number of ways to do one of these tasks is 9 + 10 = 19. Hence, the
number of integers between 4 and 100 that end with 3 or 5 is 19. That is, task T can be
completed in 19 ways.
If we look closely at the preceding counting method, we see that it is connected with the
union of two disjoint sets. For example, task T is the union of tasks T
1
and T
2
.
Addition Principle: Suppose that tasks T
1
, T
2
, , T
k
can be done in n
1
, n
2
, , n
k
ways,
respectively. If all these tasks are independent of each other, then the number of ways to do
one of these tasks is
n
1
+n
2
+ +n
k
Example 2.1.1. There are three boxes containing books. The rst box contains 15 math-
ematics books by dierent authors, the second box contains 12 chemistry books by dierent
authors, and the third box contains 10 computer science books by dierent authors. A student
wants to take a book from one of the three boxes. In how many ways can the student do this?
Solution. If the student wants to take a mathematics book, then he/she can choose one
mathematics book from 15 dierent mathematics books and he/she can do this in exactly
5
2.1 Basic Counting Principles 6
15 ways. Similarly, the student can choose one chemistry book in exactly 12 ways and one
computer science book in exactly 10 ways. Suppose tasks T
1
, T
2
, and T
3
are as follows:
T
1
: Choose a mathematics book
T
2
: Choose a chemistry book
T
3
: Choose a computer science book
Then tasks T
1
, T
2
, and T
3
can be done in 15, 12, and 10 ways, respectively. All of these tasks
are independent of each other. Hence, the number of ways to do one of these tasks is
15 + 12 + 10 = 37 ways
2.1.2 Multiplication Principle
Let us consider the following problem. Suppose we want to nd the number of words of length
3 that can be written using the letters A, B, C, D, and E such that no repetition of letters in
a word is allowed. For example, BAD, ACB, AEB, BAE, BCE, and EDA are some of the
words of length 3 that do not contain repetition of letters.
Let T be the task of constructing such a word and let X denote such a word. Then T can be
completed in three successive steps, T
1
, T
2
and T
3
, in which;
T
1
: Choose the rst letter.
T
2
: Choose the second letter.
T
3
: Choose the third letter.
The rst letter of X can be any one of the letters A, B, C, D, or E. Therefore, the rst letter
of X can be chosen in 5 dierent ways. Thus, step T
1
can be completed in 5 dierent ways.
Once the rst letter of X is chosen, the number of remaining letters in the given set is 4.
Therefore the second letter of X can be any one of the remaining 4 letters, so the second letter
of X can be chosen in 4 ways. Thus, step T
2
can be completed in 4 dierent ways.
Suppose we choose A as the rst letter of X.
A
Because repetitions of a letter are not allowed, in the second place we can put any one of the
letters B, C, D, or E.
AB, AC, AD, AE
If follows that for each choice of completing step T
1
, step T
2
can be completed in 4 ways.
Hence, we nd that steps T
1
and T
2
can be completed in 5 4 dierent ways.
After choosing the rst and the second letters of X, the number of remaining letters in the
given set is 3. Therefore, the third letter of X can be any one of these 3 letters. Thus, the
third letter can be chosen in 3 ways: i.e., step T
3
can be completed in 3 ways.
Suppose we have chosen A in step T
1
and B in step T
2
.
A, B
2.1 Basic Counting Principles 7
Then we can complete step T
3
in three dierent ways.
ABC, ABD, ABE
Because steps T
1
and T
2
can be completed in 5 4 ways, for each of these choices of 5 4 dierent
ways, we can complete step T
3
in 3 dierent ways. Consequently, steps T
1
, T
2
, and T
3
can be
completed in 5 4 3 dierent ways. Hence, there are 60 dierent words of length 3 such that
no word contains a repetition of letters.
Let us now consider a variation of the preceding problem. Suppose we want to nd the
number of words of length 3 that can be written by using the letters A, B, C, D and E such
that repetition of letters in a word is allowed. BAB, ACB, AEE, BAA, BCE, and DDA are
examples of such words of length 3.
As before, let T be the task of constructing such a word of length 3 and let t be such a
word. The task T can be completed in three successive steps, T
1
, T
2
, and T
3
.
T
1
: Choose the rst letter.
T
2
: Choose the second letter.
T
3
: Choose the third letter.
The rst letter of t can be any one of the letters A, B, C, D, or E. Therefore, the rst letter of t
can be chosen in 5 dierent ways. This implies that step T
1
can be completed in 5 dierent ways.
Because repetition of a letter is allowed, the second letter of t can be any one of the let-
ters A, B, C, D, or E. Therefore, the second letter of t can be chosen in 5 dierent ways. That
is, step T
2
can be completed in 5 dierent ways.
Suppose we choose A as the rst letter.
A
Because repetition is allowed, in the second place we can write any one of the letter A, B, C, D,
or E.
AA, AB, AC, AD, AE
It follows that steps T
1
and T
2
can be completed in 5 5 dierent ways.
Next, the third letter of t can be any one of A, B, C, D, or E. Therefore, the third letter
can be chosen in 5 ways. Suppose we chose A in the rst step, T
1
, and B in the second step,
T
2
.
AB
Then we can complete the third step, T
3
, in 5 dierent ways
ABA, ABB, , ABC, ABD, ABE
We nd that for each of the 5 5 dierent ways of completing steps T
1
and T
2
, we can complete
step T
3
in 5 dierent ways.
Consequently, steps T
1
, T
2
, and T
3
can be completed in 5 5 5 dierent ways. Hence, there are
125 dierent words of length 3 such that a word may contain repetition of letters.
2.1 Basic Counting Principles 8
Multiplication Principle: Suppose that a task T can be completed in k successive steps.
Suppose step 1 can be completed in n
1
dierent ways, step 2 can be completed in n
2
dier-
ent ways, and in general, no matter how the preceding steps are completed, step k can be
completed in n
k
dierent ways. Then the task T can be completed in
n
1
n
2
n
k
dierent ways.
Example 2.1.2.
2.1.3 Simultaneously Using Addition and Multiplication
The counting problems that we have considered so far involved either the addition principle
or the multiplication principle. Sometimes, however, we need to use both of these counting
principles to solve a particular problem.
Example 2.1.3. Determine the number of license plates that can be formed with 3 uppercase
letters followed by 3 digits such that the rst letter is either A or B.
Let X
1
be the set of all license plates with 3 uppercase letters followed by 3 digits such that
the rst letter is A. Let X
2
be the set of all license plates with 3 uppercase letters followed
by 3 digits such that the rst letter is B. Then X
1
X
2
is the set of all license plats with 3
uppercase letters followed by 3 digits that can be formed such that the rst letter is either A
or B. Because the license plates in the set X
1
begin with A and the license plates in the set
X
2
begin with B, it follows that X
1
X
2
= . By the addition principle,
[X
1
X
2
[ = [X
1
[ + [X
2
[.
Next we determine the number of elements in X
1
and the number of elements in X
2
. Let L be
a license plate in X
1
. Then L is of the form:
A
l
1
l
2
l
3
d
1
d
2
d
3
The rst letter can be chosen in only one way, each of the second and third letters can be
chosen in 26 ways, and each of the digits can be chosen in 10 ways. Thus, by the multiplication
principle, the license plate L can be formed in;
1 26 26 10 10 10 = 676, 000
ways. Hence, [X
1
[ = 676, 000.
A license plate in the set X
2
must begin with the uppercase letter B. By arguments sim-
ilar to those determining the number of elements in X
1
, the number of elements in X
2
is
676,000; that is, [X
2
[ = 676, 000. It now follows that
[X
1
X
2
= [X
1
[ + [X
2
[ = 676, 000 + 676, 000 = 1, 352, 000.
Therefore, the number of license plates with 3 uppercase letters followed by 3 digits that can
be formed such that the rst letter is either A or B is 1,352,000.
Example 2.1.4. The following items are available for breakfast: 4 types of cereal, 2 types
of juice, and 3 types of bread. Determine the number of ways a breakfast can be prepared if
exactly two items are selected from two dierent groups.
2.1 Basic Counting Principles 9
Solution. Because exactly two items must be selected from two dierent groups, a breakfast
can be prepared in either of the following three ways:
(i). a cereal and a juice, or
(ii). a cereal and a bread, or
(iii). a juice and a bread
Let
X be the set of breakfasts that consist of a cereal and a juice;
Y be the set of breakfasts that consist of a cereal and a bread; and
Z be the set of all breakfasts that consist of a juice and a bread.
Then X Y Z is the set of all breakfasts that consist of exactly two items from two dierent
groups. Notice that X Y = , X Z = , and Y Z = ; that is, the sets X, Y , and Z are
pairwise disjoint.
We can now apply the addition principle to conclude that
[X Y Z[ = [X[ + [Y [ + [Z[.
Next we determine, [X[, and [Y [, and [Z[.
A breakfast in set X consists of a cereal and a juice. Thus, we can rst select a cereal and then
a juice. Now a cereal can be selected in 4 ways and a juice can be selected in 2 ways. Thus,
by the multiplication principle, a breakfast consisting of a cereal and a juice can be prepared
in 4 2 ways. therefore, [X[ = 8. In similar manner, we can show that [Y [ = 4 3 = 12 and
[Y [ = 2 3 = 6. Consequently,
[X Y Z[ = [X[ + [Y [ + [Z[ = 8 + 12 + 6 = 26.
2.1.4 The Principle of Inclusion-Exclusion
Consider two nite sets, X
1
and X
2
. To count the number of elements in X
1
X
2
, we rst
count the number of elements in X
1
and then add the number of elements in X
2
. However, in
this process the elements that are common to X
1
and X
2
are counted twice-once to determine
[X
1
[ and the second time to determine [X
2
[. Therefore, to determine the number of elements
in X
1
X
2
, we must subtract [X
1
X
2
[ from [X
1
[ + [X
2
[, i.e.,
[X
1
X
2
[ = [X
1
[ + [X
2
[ [X
1
X
2
[
Let A and B be any nite sets. Then
n(A B) = n(A) +n(B) n(A B).
Example 2.1.5. Let A be the set of positive integers that are 30 and multiples of 4. Let
B be the set of positive integers that are 30 and multiples of 6. We want to determine the
number of distinct elements in A B.
Now A = 4, 8, 12, 16, 20, 24, 28 and B = 6, 12, 18, 24, 30. Then A B = 12, 24. Also,
[A[ = 7, [B[ = 5, and [A B[ = 2. Hence,
[A B[ = [A[ + [B[ [A B[ = 7 + 5 2 = 10.
A direct calculation, i.e., writing the elements of A B, also shows that [A B[ = 10.
Another way to nd the number of elements in A is as follows: Because A is the set of
positive integers that are 30 and multiples of 4, it follows that [A[ =
30
4
| = 7.
2.1 Basic Counting Principles 10
Example 2.1.6. Let A denote the set of bit strings of length 6 that begin with 101 and B
denote the set of bit strings of length 6 that terminate at 00. Determine the number of elements
in A B.
Solution. An element of A is of the form 101a
4
a
5
a
6
, where each a
i
is 0 or 1. Therefore, by
the multiplication principle, the number of elements in A, [A[ = 2 2 2 = 8.
An element of B is of the form b
1
b
2
b
3
b
4
00, where each b
i
is 0 or 1. It follows that the number
of elements in B is [B[ = 2 2 2 2 = 16.
Let us now count the number of elements in A B. An element of A B is a bit string
of length 6 that starts with 101 and ends with 00. Thus, an element of A B is of the form
101c
4
00, where c
4
is 0 or 1. It follows that the number of elements in A B, [A B[ = 2.
[A B[ = [A[ + [B[ [A B[ = 8 + 16 2 = 22.
Example 2.1.7. How many positive integers 100 are multiples of 4, 5, or 6?
Question 2.1.1. How many positive integers 1, 000 are multiples of
(a). 2, 3,or 5?
(b). 4, 6 or 20?
(c). not multiples of 4, 6, or 20?
(d). not multiples of 8, 12 , or 20?
Question 2.1.2. How many positive integers 100 are multiples of 2 or multiples of 3?
Question 2.1.3. How many positive integers 200 are multiples of
(a). 3 or 5?
(b). 4 or 6?
(c). not multiples of 2 or 17?
(d). not multiples of 12 or 16?
Next we extend formula to three nite sets, A, B, and C. We thus have;
[A B C[ = [A[ + [B[ + [C[ [A B[ [A C[ [B C[ + [A B C[
where A, B, C are nite sets.
Example 2.1.8. Determine all positive integers less than 2102 that are divisible by at least
one of the primes 2, 3, and 5.
Solution. Let A, B and C be the set of all positive integers that are less than or equal to
2102 and divisible by 2, 3, and 5 respectively i.e.,
A =< 2 >, [A[ = 2102/2| = 1051
B =< 3 >, [B[ = 2102/3| = 700
C =< 5 >, [C[ = 2102/5| = 420
2.1 Basic Counting Principles 11
Now AB is the set of all positive integers that are divisible by 2 and 3. Because 2 and 3 are
relatively prime, we can show that an integer is divisible by 2 and 3 if and only if it is divisible
by 6. Thus,
A B =< lcm(2, 3) >=< 6 >, [A B[ = 2102/6| = 350
A C =< lcm(2, 5) >=< 10 >, [A C[ = 2102/10| = 210
B C =< lcm(3, 5) >=< 15 >, [B C[ = 2102/15| = 140
A B C =< lcm(2, 3, 5) >=< 30 >, [A B C[ = 2102/30| = 70
Consequently, by the inclusion-exclusion principle,
[A B C[ = [A[ + [B[ + [C[ [A B[ [A C[ [B C[ + [A B C[
= 1051 + 700 + 420 350 210 140 + 70
= 1, 541
Note: The principle of inclusion-exclusion can be generalized to a nite number of sets. This
can be proved by using mathematical induction.
Question 2.1.4. Generalize the above formula for four sets.
Question 2.1.5. Find the number of positive integers less than or equal to 500 and are
(i). divisible by 3
(ii). divisible by 5
(iii). divisible by 7
(iv). divisible by 3 and 5
(iv). divisible by 3 and 7 or 5
(iv). neither divisible by 3 nor divisible by 7.
2.1.5 Pigeonhole Principle
If n pigeonholes are occupied by n+1 or more pigeons, then at leat one pigeonhole is occupied
by more than one pigeon.
The Pigeonhole Principle: Suppose there are n pigeons, k pigeonholes, and n > k. If
these n pigeons y into these k pigeonholes, then some pigeonhole must contain at least two
pigeons.
Notice that the pigeonhole principle only tells us that an object with the desired property
exists. It does not tell us which object has the desired property or how to nd that object.
The pigeon principle is also known as the Direchlet drawer principle, or the shoebox prin-
ciple. This principle was rst formally stated by Peter Gustave Lejeune Dirichlet (1805-1859).
In order to apply the pigeonhole principle, we need to specify which objects are pigeons and
which objects are pigeonholes.
Let us consider the following problems:
2.1 Basic Counting Principles 12
Example 2.1.9. There are 13 people in a room. At least 2 of these 13people must be born in
the same month.
Here we can think of months as pigeonholes and people in the room as pigeons. Then, because
there are 13 people, n = 13. Similarly, because there are 12 months in a year, k = 12.
Therefore, n = 13 > 12 = k. Because n > k, by the pigeonhole principle, at leat 2 people must
be born in the same month.
Example 2.1.10. Sometimes airlines hoping for cancelation, overbook ights. If 101 people
are booked for a trip and the plane has only 100 seats then at least 2 people must be assigned
the same seat.
Here the seats are the pigeonholes and the passengers holding the seats as pigeons. Then
n = 101, and k = 100. Because n > k, by the pigeonhole principle, at least 2 people must be
assigned the same seat.
Example 2.1.11. A student must take ve classes from classes from three areas of study.
Numerous classes are oered in each discipline, but the student cannot take more than two
classes in any given area. Using the inclusion - exclusion principle, show that the students will
have to take at least one class in each area.
Generalized Pigeonhole Principle:
Suppose that there are n pigeons k pigeonholes, n > k, and m = ,
n
k
|. If these n pigeons y
into these k pigeonholes, then some pigeonholes must contain at least m pigeons.
Example 2.1.12. Suppose there are 50 people in a room. Find the minimum number of
people that must have their birthday in the same month.
Solution. We can think of the people as pigeons and the months as pigeonholes. Then n = 50,
k = 12, and
m = ,
50
12
| = 5
By the generalized pigeonhole principle, at least 5 people must have their birthday in the same
month.
Question 2.1.6. There are 400 students in a programming class. show that at least two of
them were born on the same day of a month.
n = 400, k = 30 days.
m = ,
n
k
| = ,
400
12
|
Question 2.1.7. Suppose there is a group of 10 senators. Each senator must serve in one of
eight committees. Show that there is at least one committee with more than one senator.
Question 2.1.8. From the integer in the set 1, 2, , 20, what is the least number of
integers that must be chosen so that at least one of them is divisible by 4?
Question 2.1.9. In a group of 38 people, at least how many must have been born in the same
month?
Question 2.1.10. A group of 40 students in a class must show a set of 15 computers. To
avoid conict, each student is assigned only one computer. Moreover, no computer is assigned
to more than 4 students. Prove that at least 2 computers are assigned to 3 or more students.
2.2 Permutation and Combinations 13
2.2 Permutation and Combinations
2.2.1 Factorial Notation
The product of the positive integers from 1 to n inclusive is denoted by n! (read as n factorial):
n! = n (n 1) (n 2) 3 2 1
e.g 5! = 5 4 3 2 1 and 0! = 1.
Note: n cannot take negative values.
2.2.2 Permutations
A permutation is an ordered arrangement to every or some elements of a set of objects. Order
is important in a permutation, therefore permutations with the same objects in a dierent
order are considered distinct arrangements. Some of the objects in the set, as well as in a
permutation, may be indistinguishable from one another.
A permutation of n distinct objets taken r at a time is a subset, with r elements, of the
n distinct objects. The number of these subsets denoted by
n
P
r
is equal to
P(n, r) =
n
P
r
=
n!
(n r)!
= n(n 1)(n 2) (n r + 1)
Note: P(n, n) = n!.
Example 2.2.1. Given the letters A, B, C, D, E, F and G, how many arrangements of these
seven letters taken 4 at a time do we have?
Solution. Let n = 7 and r = 4, Thus;
7
P
4
=
7!
(7 4)!
=
7!
3!
= 840 arrangements
If all n distinct elements of a set are to be arranged, then each arrangement is a permutation
of n distinct objects taken n at a time. The number of such permutations is
n
P
n
=
n!
(n n)!
=
n!
0!
= n!
Example 2.2.2. In how many ways can we arrange the three letters A, B, and C in a row
from left to right?
Solution. Let n = 3 and r = 1, thus;
3
P
3
= 3! = 6 ways
Question 2.2.1. Three schools have teams of six or more runners in a cross country race. In
how many ways can the rst six places be taken by the three schools, if there is no dead heats?
Solution. Here, for all schools
3 3 3 3 3 3 = 3
6
ways
The rst 6 places may be taken by the three schools.
2.2 Permutation and Combinations 14
Circular Permutations
Circular permutations are ordered arrangements of objects in a circle. While order is still
considered, a circular permutation is not considered to be distinct from another unless at least
one object is preceded or succeeded by a dierent object in both permutations.
In the set of objects, one object can be xed, and the other objects can be arranged in dierent
permutations. Thus, the number of permutations of n distinct objects that are arranged in a
circle is (n 1)!.
Example 2.2.3. How many ways can 6 persons sit at a circular dinner table?
Solution. There are (6 1)! = 5! = 120 ways to seat 6 persons in a circular table.
Permutations with Repetitions
If there are identical or indistinguishable objects in the set, then the number of possible per-
mutations in the set will be less than the number of permutations with distinct objects. This
is true because permutations that are exactly alike, except that the identical objects have
changed positions (e.g. an object switches position with an identical object) are considered to
be the same arrangement.
The number of distinct permutations of n objects of which n
1
are of one kind, n
2
are of a
2nd kind, n
k
are of kth kind, is given by
P(n; n
1
, n
2
, , n
k
) =
n!
n
1
!n
2
! n
k
!
where n
1
+n
2
+n
3
+ +n
k
= n.
Example 2.2.4. How many seven-letter words can be formed using the letters of the word
BENZENE?
Solution. We seek the number of permutations of seven objects of which 3 are alike (the three
Es), and two are alike (the two Ns).
P
(7;3,2)
=
7!
3!2!
= 420 ways
Example 2.2.5. How many nine-letter permutations can be created using the letters from
the word TENNESSEE?
Solution. The word TENNESSEE has 4Es, 2Ss and 1T and 2Ns.
P
(9;4,2,2)
=
9!
4!2!2!
=
15120
4
= 3780 ways
Example 2.2.6. From a pack of playing cards, the ACE, KING, QUEEN and JACK and 10
of Spades are taken. In how many ways can three of these ve cards be placed in a row from
left to right?
Solution. Here we have ve cards from which to choose three at a time.
5
P
3
=
5!
(5 3)!
= 60 ways
2.2 Permutation and Combinations 15
Example 2.2.7. How many even numbers greater than 2,000, can be formed with the digits
1, 2, 4, and 8, if each digit may be used only once in each number?
3 2 2 1 = 12 (without repetition of numbers).
Example 2.2.8. Five letters from the word DRILLING are arranged in a row. Find the
number of ways in which this can be done, when the rst letter is I and the last is L,
a). If no letter may be repeated
b). If each letter may occur as many times as it does in DRILLING.
Solution. Here we have the rst and the last letters xed. Only the middle digits can take
dierent letters.
1st letter 2nd 3rd 4th 5th
I 4 3 2 L
Hence 4 3 2 = 24 ways.
1st letter 2nd 3rd 4th 5th
I 6 5 4 L
Hence 5 5 4 = 120 ways.
Example 2.2.9. In a hockey match, the game(match) can won, drawn or lost. If a team plays
ve matches, how many dierent sequences of results are possible.
Solution. The rst match has 3 possible outcomes (win, draw, or lose). Similarly all the other
matches have 3 possible outcomes.
3 3 3 3 3 = 3
5
= 243
Example 2.2.10. How many dierent six gure phone numbers are possible if the digits 0 to
9 are allowed, except that the rst digit must be 7, 8, or 9?
Solution. Here:
Telephone number has 6 digits
1st number can have only three possible choices.
Each of the others has ten possible choices.
Digit: First Second Third Fourth Fifth Sixth
No. of Choices: 3 10 10 10 10 10
Hence the total number of possible outcomes is
3 10
5
= 300, 000
Example 2.2.11. A car registration in the country of Burania consists of three letters, followed
by three digits. The rst letter is always A, and the other two letter should not include A, I,
or O and must be dierent. The rst digit must not be zero, but otherwise any digits may be
used in any of the three places. How many dierent registrations are there?
Solution. Setting out the possibilities, we have
Letters Digits
First Second Third First Second Third
1 23 22 9 10 10
So altogether there are
1 23 22 9 10 = 455, 400 dierent registrations.
Example 2.2.12. In how many ways can 11 books be arranged on a shelf.
11! = 39, 916, 800.
2.2 Permutation and Combinations 16
Exercises
1. How many ve-digit odd numbers can be made from the digits 1, 2, 3,4, 5 if no digit is
repeated?
2. How many numbers between 3,000 and 4,000, with distinct digits, can be formed using
the digits 1, 3, 4, 5, and 6?
3. Determine the four-digit numbers, with distinct digits, that can be formed using the
digits 0, 1, 2, 3, 4, 5, and 6 such that none of the numbers have a leading 0.
4. Find the number of six-letter words that can be formed from the letters of the word
HISTORY if no letter is used more than once in any word subject to the conditions
given below:
(a). The rst letter of each word is H.
(b). The rst letter of each word is either H or Y .
(c). The word starts with HIS.
(d). The word contains HIS as a substring.
5. In how many ways can four letters of the word BRIDGE be arranged in a row, if now
letter is repeated?
6
P
4
=
6!
(6 4)!
=
6!
2!
= 360 ways.
Alternatively
Letter 1st 2nd 3rd 4th
No. of letters: 6 5 4 3
Hence 6 5 4 3 = 360 ways.
6. The computer department in a large company assigns a personal code number to each
employee in the form of a three-digit number, using the digits 0 to 9 inclusive. Code
numbers starting with 0 are reserved for members of the management. How many code
numbers are available for non-management employees?
7. A student has two coats, four scarves, and three pairs of shoes. How many dierent
outts, consisting of coat, scarf and a pair of shoes, can she make out of these.
2 4 3 = 24 dierent outts
8. Four men and their wives sit on a bench. In how many ways can they be arranged if
(a) there is no restriction,
(b) each man sits nest to his wife?
2.2 Permutation and Combinations 17
2.2.3 Combinations
LetS be a set with n > 0 elements. Let r be an integer such that 0 r n. An r-combination
of S or a combination of the elements of S taken r at a time is a subset A of S such that A
contains r elements of S.
A combination of n distinct objects taken r at a time is a subset of the n objects with r
elements. A combination essentially creates a partition of the n objects into two cells, with
r objects in the rst cell and (n r) objects in the second cell. Therefore, the number of
combinations of n distinct objects taken r at a time is
C(n, r) =

n
r

=
N
C
r
=
n!
r!(n r)!
C(n, r) =
P(n, r)
P(r, r)
Note: Unlike a permutation, a combination does not take order into account.
Theorem 2.2.1. Let S be a set with n > 0 elements. Let r be an integer such that 0 r n.
Then
C(n, r) = C(n, n r).
Proof.
C(n, n r) =
n!
(n r)!(n (n r))!
=
n!
(n r)!(n n +r)!
=
n!
r!(n r)!
= C(n, r).
Theorem 2.2.2. Suppose there is a collection of n objects of k dierent types. Assume that
objects of the same type cannot be distinguished from each other. Suppose each type contains
n
i
objects, i = 1, 2, , k, (n = n
1
+ n
2
= n
3
+ + n
k
). Then the total number of dierent
arrangements of these n objects of k dierent types taken all at a time is:
C(n, n
1
) C(n n
1
, n
2
) C(n n
1
n
2
, n
3
) C(n n
1
n
2
n
k1
, n
k
),
which equals
n!
n
1
!n
2
! n
k1
!n
k
!
Each of the
n!
n
1
!n
2
! n
k1
!n
k
!
is called a generalized arrangement, or generalized permutation,
of the n objects of k dierent types taken all at a time.
Theorem 2.2.3. Let n and r be two positive integers such that r n. Then the number of
r-combinations of n objects with repetitions allowed is
C(n 1 +r, r).
Example 2.2.13.
8
C
5
=
8!
5!(8 5)!
=
8!
5!3!
Question 2.2.2. Suppose a candy shop has six dierent varieties of candy. Kamau wants to
buy four candies. We want to know the number of ways Kamau can do this.
2.2 Permutation and Combinations 18
Exercises
1. In how many ways can 13 cards be selected from a pack of 52 playing cards?
52
C
13
=
52!
39!13!
2. A mixed hockey team containing 5 men and 6 women is to be chosen from 7 men and 9
women. In how many ways can this be done?
7
C
5

9
C
6
=
7!
2!
5!
9!
3!
6! = 21 84 = 1764 ways
3. A party of twelve is to dine at three tables at a hotel. In how many ways may they be
split if each table holds four?
4. Twelve people are to travel by three cars, each of which holds four. Find the number of
ways in which the party may be divided if two people refuse to travel in the same car.
5. A ferry which holds ten people carries a party of thirteen men and seven women across a
river. Fund the number of ways in which the party may be taken across if all the women
go on the rst trip.
6. In a game of mixed hockey there are ten married couples and two spinsters playing. In
how many ways can the two teams be made up, if no husband may play against his wife?
7. Nine people are going to travel in two taxis. The larger has ve seats, and the smaller
has four. In how many ways can the party be split up?
8. How many mixed hickey teams may be made from six married couples, one bachelor and
three spinsters, if no wife will play without her husband?
9. The computer department in a large company assigns a personal code number to each
employee in the form of a three-digit number, using the digits 0 to 9 inclusive. Code
numbers starting with 0 are reserved for members of the management. How many code
numbers are available for non management employees?
10. Twelve people are to travel by three cars, each of which holds four. Find the number of
ways in which the party may be divided if two people refuse to travel in the same car.
11. In how many ways can a customer at the supermarket select three dierent types of soda
from thirty available types, and ten dierent packets of biscuits from twelve dierent
available packets?
12. A man, who works a ve-day week, can travel to work on foot, by cycle or by bus. In
how many ways can he arrange a weeks traveling to work. 3
5
= 243 ways.
13. Seven men and six women are to be seated in a row on a platform. In how many ways
can they be arranged if no two men sit next to each other? In how many ways can the
arrangement be made if there are six men and six women, subject to the same restrictions.
14. A man stays three days at a hotel and the menu is the same for breakfast each day.
He may have any one of three types of egg dish, or two types of sh, or meat. In how
many ways can he order his three breakfast if he does not have eggs two days running
(consecutively) nor repeat any dish?
2.2 Permutation and Combinations 19
15. Find the number of ways in which the letters of ISOSCELES can be arranged if the two
Es are separated.
16. There are six contestants for the post of chairman, secretary and treasurer. These posi-
tions can be lled by any of the 6. Find the possible number of ways in which the three
positions may be lled.
The number of ways of lling the three positions are 654 = 120 ways. Alternatively,
6
P
3
=
6!
(6 3)!
=
6!
3!
= 120 ways
17. In how many ways can a committee consisting of three men and two women be chosen
from seven men and ve women?
18. The computer department in a large company assigns a personal code number to each
employee in the form of a three-digit number, using the digits 0 to 9 inclusive. Code
numbers starting with 0 are reserved for members of the management. How many code
numbers are available for non management employees?
19. Twelve people are to travel by three cars, each of which holds four. Find the number of
ways in which the party may be divided if two people refuse to travel in the same car.
Chapter 3
Relations
Introduction
Relations are a natural way to associate objects of various sets. For example, we can take the
set, say A, of people in a town and the set, say B, of businesses in that town. We can say that
an element a of A is related to an element b of B, if a is an employee of b.
As another example, we can take the set F of farmers and the set V of vegetables. We
can relate the elements of F to the elements of V by dening that an element a of F is related
to an element b of V if a grows b. The obvious question is how to represent relations in math-
ematics.
A binary relation, or simply a relation, R from a set A into a set B is a subset of AB.
Let R be a relation from A into B, i.e., R A B. If (a, b) R, we say that, a is R-
related; if the relation under consideration is understood) to b and write aRb (or, R(a) = b).
If (a, b) R, i.e., if a is not R-related to b, we denote it by
a
R
b
.
Product Set
Consider the arbitrarily sets A and B. The set of all ordered pairs (a, b) where a A and
b B is called the product, or cartesian product of A and B.
AB = (a, b) : a Aand b B
Example 3.0.14. Let A = 1, 2 and B = a, b, c. Then
AB = (1, a), (1, b), (1, c), (2, a), (2, b), (2, c)
B A = (a, 1), (b, 1), (c, 1), (a, 2), (b, 2), (c, 2)
AA = (1, 1), (1, 2), (2, 1), (2, 2)
Note: AB ,= B A
The cartesian product deals with ordered pairs, so naturally the order in which the sets are
considered is important.
Using n(S) for the number of elements in a set S, we have
n(AB) = 6 = 2 3 = n(A) n(B).
In fact n(AB) = n(A) n(B) for any nite sets A and B.
20
3.1 Binary Relations 21
Example 3.0.15. Let S = 2, 3, 5, 6, R means divides. State which pairs are related.
2R2, 2R6, 3R3, 3R6, 5R5, 6R6
Example 3.0.16. Let S = 1, 2, 3, , 20, R =is three times,
3R1, 6R2, 9R3, 12R4, 15R5, 18R6
Example 3.0.17. R = (x, y) : 2x y = 6, x R. Determine three members of R.
(4, 2), (0, 6), (1, 4)
Find three more
(2, 10), (3, 0), (2, 2)
Example 3.0.18. Let
A = Kisumu, Garissa, Nyeri, Kakamega, Nakuru
B = Central, Rift-Valley, Nyanza, North-Eastern, Western
Let x A and y B. Dene the relation between x and y by x is the headquarter of
y.
Using the relation, we can make the following ordered pairs: (Kisumu, Nyanza), (R.V, Nakuru),
(Kakamega, Western), (Garissa, N.E).
3.1 Binary Relations
Any relation R on a set S, between two members of S is known as a binary relation on S
and is a subset of S S.
Example 3.1.1. Let
(a). S = 2, 3, 5, 6, R means divides. State which pairs are related.
2R2, 2R6, 3R3, 3R6, 5R5, 6R6
(b). S = 1, 2, 3, , 20, and R = is three times. List the relations that are valid
3R1, 6R2, 9R3, 12R4, 15R5, 18R6,
(c). R = (x, y) : 2x y = 6, x R. Determine three members of R.
(4, 2), (0, 6), (1, 4), (2, 10), (3, 0), (2, 2)
3.1.1 Properties of Binary Relations
Reexive relations
A relation R on a set S is called reexive whenever aRa for every a S.
Example 3.1.2. Let
(a). On the set of all triangles in a plane, say T, Let R = is congruent to
So R is reexive.
For all t T, t T, tRt so R is reexive.
3.1 Binary Relations 22
(b). For some set T let R =has twice the area of is R reexive?
Clearly R is not reexive.
(c). Consider the following ve relations on the set A = 1, 2, 3, 4.
R
1
= (1, 1), (1, 2), (2, 3), (1, 3), (4, 4)
R
2
= (1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)
R
3
= (1, 3), (2, 1)
R
4
= , the empty relation.
R
5
= AA, the universal relation.
Determine which of the relations are reexive.
Solution. Only R
2
and the universal relation R
5
= AA are reexive.
Note: R
1
, R
3
and R
4
are not reexive since, for example (2, 2) doesnt belong to any of them.
Symmetric relations
A relation R on a set S is called symmetric if whenever aRb then bRa; that is, if whenever
(a, b) R then (b, a) R. Thus R is not symmetric if there exists a, b A such that (a, b) R
but (b, a) not in R.
From the example above, determine which of the relations are symmetric.
R
1
is not symmetric since, (1, 2) R
1
, but (2, 1) not in R
1
.
R
3
is not symmetric since (1, 3) R
3
but (3, 1) not in R
3
.
The other relations are symmetric.
Antisymmetric relations
A relation R on a set A is antisymmetric if whenever aRb and bRa then a = b, that is, if
whenever (a, b), (b, a) R then a = b.
Thus R is not antisymmetric if there exists a, b A such that (a, b) and (b, a) belong to
R, but a ,= b.
From the above example,
R
2
is not antisymmetric since (1, 2) and (2, 1) belong to R
2
, but 1 ,= 2.
Similarly, the universal relation R
5
is not antisymmetric.
All the other relations are antisymmetric.
Note: The properties of being symmetric and being antisymmetric are not negative of each
other.
For example, the relation R = (1, 3), (3, 1), (2, 3) is neither symmetric nor antisymmetric.
3.1 Binary Relations 23
On the other hand, the relation R

= (1, 1), (2, 2) is both symmetric and antisymmetric.


Transitive relations
A relation R on a set A is transitive if whenever aRb and bRc then aRc, that is, if whenever
(a, b), (b, c) R then (a, c) R. Thus R is not transitive if there exists a, b, c a such that
(a, b), (b, c) R but (a, c) is not in R.
For the above example, determine which of the relations are transitive.
The relation R
3
is not transitive, since (2, 1), (1, 3) R
3
but (2, 3) is not in R
3
.
Example 3.1.3. Let S be the set of all lines in a plane and R =is parallel to. Is R transitive?
If aRb, bRc, and aRc, then R is transitive.
Example 3.1.4. For the same set S, R =is perpendicular to. Is R transitive?
If aRb and bRc the C is parallel to a, so we do not have aRc. Hence R is not transitive.
Equivalence Relations
Let A be a set and let R be a relation on A. Then R is called
(i). reexive, if for all a A,
a
R
a
;
(ii). symmetric, if for a, b, c A, whenever
a
R
b
and
b
R
a
must also hold;
(iii). transitive, if all a, b, c A, whenever
a
R
b
and
b
R
c
hold,
a
R
c
must also hold.
Let A be a set and let R be a relation on A. Observe that
R is not reexive, if there exists a, b A such that (a, a) is not in R;
R is not symmetric, if there exists a, b A such that (a, b) R, but (b, a) not in R.
R is not transitive, if there exists a, b, c A such that (a, b) R, (b, c) R but (a, c)
not in R.
A relation R on a set A is called an equivalence relation if R is reexive, symmetric, and
transitive.
Example 3.1.5. Let A = a, b, c, d and R = (a, b), (b, b), (c, c), (d, d), (a, b), (b, a). Show
that R is an equivalence relation on A.
Theorem 3.1.1. Let R be a relation on a set A. Then R is an equivalence relation on A if
and only if
(i).
A
R, where
A
= (a, a)[a A.
(ii). R = R
1
, and (Inverse)
(iii). R R R (composition)
3.1 Binary Relations 24
Example 3.1.6. Conrm that the relation is equal to on a set of real numbers is an equiv-
alence relation.
x = xx R hence reexive
x = y y = xx R symmetrical
x = y = z x = zx R transitive.
The relation is an equivalence relation.
Example 3.1.7. Is the relation has the same surname as on the set p of people in the block
of ats in Kingongo an equivalence relation?
Proof. (i). x has the surname as x so reexive.
(ii). x has the same surname as y, then y has the same surname as x, so symmetric.
(iii). If x has the same surname as y, y has the same surname as z. then x has the same
surname as z, the relationship is transitive.
Each of the properties reexive, symmetric, and transitive holds, so the relation is an
equivalence relation on p.
Question 3.1.1. On p is the relation is the sister of an equivalence relation?
It is not an equivalence relation.
Equivalence Classes and Partitions
For any set let R be an equivalence relation on S. If a S, the set of elements y S where
yRa constitute a subset [a], of S is called an equivalence set or equivalence class.
[a] = y : y S, yRa
Let R be an equivalence relation on a set X. For all x X, let [x] denote the set
[x] = y X[
y
R
x

The subset [x] of X is called the equivalence class (R-class, or R-equivalence class) of the
equivalence relation R determined by x.
The relation
R = (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 4), (4, 1), (2, 3), (3, 2)
on the set A = 1, 2, 3, 4, 5 is an equivalence relation. The equivalence class [1] is the subset
of those elements of A that are related to 1. Because only
1
R
1
and
4
R
1
, we have [1] = 1, 4.
Question 3.1.2. For the set T of triangles in a plane and R =is congruent to. Check if R
is an equivalence relation. Give an example of an equivalence class (equivalence set).
The following theorems furnishes some fundamental properties of equivalence classes.
Theorem 3.1.2. The set (A
1
, A
2
, A
n
) of non empty subset of S will be called a partition
of set S provided
(i). A
1
A
2
A
n
= S and
3.1 Binary Relations 25
(ii). A
i
A
j
= for i ,= j,(i, j = 1, 2, , n)
An equivalence relation R on a set S eects a partition of S and conversely a partition of
S denes an equivalence relation on S.
Example 3.1.8. On S consider R = has the same remainder when divided by 3, where
S = X : 1 x 25, x N
Show that R is an equivalence relation, and partitions S into subsets dened by R.
Remainder 1 = 4, 7, 10, 13, 16, 19, 22, 25
Remainder 2 = 5, 8, 11, 14, 17, 20, 23
Symmetric and antisymmetric relations
A relation R on a set A is symmetric if whenever
a
R
b
then
b
R
a
, that is, if whenever (a, b) R
then (b, a) R. Thus R is not symmetric if there exists A, b A such that (a, b) R but (b, a)
is not in R.
A relation R on a set A is antisymmetric if whenever
a
R
b
and
b
R
a
then a = b, that is, if
whenever (a, b), (b, a) R then a = b. Thus R is not antisymmetric if there exists a, b A
such that (a, b) and (b, a) belong to R, but a ,= b.
Note: The properties of being symmetric and being antisymmetric are not negatives of each
other. For example, the relation
R = (1, 3), (3, 1), (2, 3)
is neither symmetric nor antisymmetric. On the other hand, the relation
R

= (1, 1), (2, 2)


is both symmetric and antisymmetric.
Chapter 4
Recurrence Relations
In this chapter, we look at examples illustrating recurrence relationships and discuss a method
for solving recurrence relations. By solving a recurrence relation, we mean nding an explicit
formula, a term we dene, for the nth term.
4.1 Sequences and Recurrence Relations
A sequence is simply a list of objects arranged in a denite order; a rst element, second
element, third element, and so on. The list may stop after n steps, n N, or it may go on
forever. In the rst case we say that the sequence is nite, and in the second case we say that
it is innite. The elements may all be dierent, or some may be repeated.
Example 4.1.1. The sequence 1, 0, 0, 1, 0, 0, 1, 1, 1, is a nite sequence with repeated
items.
Example 4.1.2. The list 3, 8, 13, 18, 23, is an innite sequence.
Example 4.1.3. Another innite sequence is 1, 4, 9, 16, 25, , the list of the squares of all
positive integers.
It may happen that how a sequence is to continue is not clear from the rst few terms.
Also, it may be useful to have a compact notation to describe a sequence.
Two kinds of formulae are commonly used to describe sequences.
Example ??: Adding 5 to the previous term
a
1
= 3, a
n
= a
n1
+ 5, 2 n
A formula, like this that refers to previous terms to dene the next term is called recursive.
Every recursive formula must include a starting place.
On the other hand, in Example ?? it is easy to describe a term using only its positive number.
In the nth position is the square of n; b
n
= n
2
, n 1. This type of formula is called explicit,
because it tells us exactly what value any particular term has.
Example 4.1.4. The recursive formula c
1
= 5, c
n
= 2c
n1
, 2 n 6, denes the nite
sequence 5, 10, 20, 40, 80, 160.
Example 4.1.5. The innite sequence 3, 7, 11, 15, 19, 23, can be dened by the recursive
formula
d
1
= 3, d
n
= d
n1
+ 4.
26
4.1 Sequences and Recurrence Relations 27
Example 4.1.6. The explicit formula s
n
= (4)
n
, n 1, describes the innite sequence
4, 16, 64, 256,
Example 4.1.7. The nite sequence 87, 82, 77, 72, 67 can be dened by the explicit formula
t
n
= 92 5n, 1 n 5
Question 4.1.1. Write a formula for the nth term of the sequence. Identify your formula as
recursive or explicit.
(a). 1, 3, 5, 7
(b). 0, 3, 8, 15, 24, 35,
(c). 1, 1, 1, 1, 1, 1,
(d). 0, 2, 0, 2, 0, 2,
(e). 1, 4, 7, 10, 13, 16,
(f). 1, 1/2, 1/4, 1/8, 1/16,
(g). 1, 3, 5, 9, 17, 31, 57, 105,
(h). 7, 17, 27, 37, 47, 57, , 67,
(i). 1, 1, 2, 6, 24, 120, 720,
(j). 2, 4, 5, 7, 7, 9, 12, 16, 22,
Question 4.1.2. Write an explicit formula for the sequence 2, 5, 8, 11, 14, 17, .
Question 4.1.3. Write a recursive formula for the sequence 2, 5, 7, 12, 19, 31, .
Example 4.1.8. Consider the following two sequences:
S
1
: 3, 5, 7, 9,
S
2
: 3, 9, 27, 81,
We can nd a formula for the nth term of sequence S
1
and S
2
by observing the pattern of
the sequences.
S
1
: 2 1 + 1, 2 2 + 1, 2 3 + 1, 2 4 + 1,
S
2
: 3
1
, 3
2
, 3
3
, 3
4
,
For S
1
, a
n
= 2n + 1, for n 1, and for S
2
, a
n
= 3
n
for n 1. This type of formula is called
an explicit formula for the sequence, because using this formula we can directly nd any
term of the sequence without using other terms of the sequence. For example, a
3
= 23+1 = 7.
In the preceding example, it was easy to nd an explicit formula for the nth term of the
sequence. However, there are sequences for which nding an explicit formula is not obvious.
Let us consider the following example.
Let S denote the sequence.
1, 1, 2, 3, 5, 8, 13, 21,
4.1 Sequences and Recurrence Relations 28
For this sequence, the explicit formula is not obvious. If we observe closely, however, we nd
that the pattern of the sequence is such that any term after the second term is the sum of the
preceding two terms. Now
3 rd term = 2 = 1 + 1 = 1 st term + 2 nd term
4 th term = 3 = 1 + 2 = 2 nd term + 3 rd term
5 th term = 5 = 2 + 3 = 3 rd term + 4 th term
6 th term = 8 = 3 + 5 = 4 th term + 5 th term
Hence, the sequence S can be dened by the equation
f
n
= f
n1
+f
n2
for all n 3 and
f
1
= 1
f
2
= 1
This sequence is called the Fibonacci sequence in honor of the Italian mathematician
Leonardo Fibonacci, and the terms of the sequence are called Fibonacci numbers. We see
that we can nd the nth term, n 3, of the sequence from the preceding two terms. Notice
that the values of f
1
and f
2
are given explicitly. Now because
f
3
= f
1
+f
2
,
using f
1
and f
2
, we can determine f
3
. Similarly, we have.
f
4
= f
2
+f
3
.
Therefore, using f
2
and f
3
, we can determine f
4
, and so on.
Because f
n
is dened in terms of previous terms of the sequence, equations of the form.
f
n
= f
n1
+f
n2
are called recurrence equations of recurrence relations.
A recurrence relation for a sequence a
0
, a
1
, a
2
, , a
n
, is an equation that re-
lates a
n
to some of the terms a
0
, a
1
, a
2
, , a
n2
, a
n1
for all integers n with n k, where
k is a nonnegative integer. The initial conditions for the recurrence relations are a set of
values that explicitly dene some of the members of a
0
, a
1
, a
2
, , a
k1
.
For the Fibonacci sequence f
1
= 1, f
2
= 1 gives the initial conditions.
The equation a
n
= 2a
n1
+ a
n2
for all n 2 as dened relates a
n
to a
n1
and a
n2
. Here
k = 2, so this is a a recurrence relation with initial conditions a
0
= 5 and a
1
= 7.
Example 4.1.9. Consider the function dened by f(0) = 1, f(n) = nf(n 1) for all n 1.
Then
f(0) = 1 = 0!,
f(1) = 1 f(0) = 1 = 1!
f(2) = 2 f(1) = 2 1 = 2 = 2!
f(3) = 3 f(2) = 3 2 1 = 6 = 3!
4.1 Sequences and Recurrence Relations 29
and so on.
Here f(n) = nf(n 1) for all n 1 is the recurrence relation, and f(0) = 1 is the initial
condition for the function f. Notice that the function f is nothing but the factorial function,
i.e., f(n) = n! for all n 0.
Example 4.1.10. Compound interest. Sam received a yearly bonus and deposited $10,000 in
a local bank yielding 7% interest compounded annually. Sam wants to know the total amount
accumulated after n years.
Solution. Let A
n
denote the total amount accumulated after n years. Let us determine a
recurrence relation and initial conditions for the sequence A
0
, A
1
, A
2
, ; A
3
. .
The amount accumulated after one year is the initial amount plus the interest on the ini-
tial amount. Now A
n1
is the amount accumulated after n 1 years. This implies that the
amount at the beginning of nth year is A
n1
. If follows that the total amount accumulated
after n years is the amount at the beginning of the nth year plus the interest on this amount.
Because the interets rate is 7%, the interets earned during the nth year is
(0.07)A
n1
.
Hence
A
n
= A
n1
+ 0.07A
n1
= 1.07A
n1
, n 1
A
0
= 10, 000
Thus, we nd that a recurrrence relation and initial condition for the sequence A
n

n=0
are
A
n
= 1.07A
n1
, n 1, A
0
= 10, 000.
Example 4.1.11. Tower of Hanoi. In the nineteenth century, a game called Tower of Hanoi
became popular in Europe. This game represents work that is under way in the temple of
Brahma. At the creation of the universe, priests in the temple of Brahma were supposedly
given three diamond pegs, with one peg containing 64 golden disks. Each golden disk is slightly
smaller than the disk below it. The preiests task is to move all 64 disks from the rst peg to
the third peg. the rules for moving the disks are as follows:
1. Only one disk can be moved at a time.
2. The removed disk musk be placed on one of the pegs.
3. A larger disk cannot be placed on top of a smaller disk.
The priests were told that once they had moved all the disks from the rst peg to the third
peg, the universe would come to an end.
Our objective is to determine the minimum number of moves required to transfer the disks
from the rst peg to the third peg.
In general, let peg 1 contain n 1 disks.
1. Move the top (n 1) disks from peg 1 to peg 2 using peg 3 as the intermediate peg.
2. Move disk number n from peg 1 to peg 3.
4.2 Solving Recurrence relations by Iterations (Substitution) 30
3. Move the top n 1 disks from peg 2 to peg 3 using peg 1 as the intermediate.
Let c
n
denote the number of moves required to move n disks, n 0, from peg 1 to peg 3. Step
(n) requires us to move the top n1 disks from peg peg 1 to peg 2, which requires c
n1
moves.
Step (2) requires us to move the nth disk from peg 1 to peg 3, which requires 1 move. Step
(3) requires us to move (n 1) disks from peg 2 to peg 3 which requires c
n1
moves. Thus, it
follows that c
n
= 2c
n1
+ 1 if n > 1 and c
1
= 1.
Now the above is a recurrence relation for the sequence c
n

n=1
with the initial condition
given by c
1
= 1.
Example 4.1.12. Rabbits on an Island. The following problem was proposed by Leonardo
Fibonacci in the thirteenth century in his book Liber abaci.
A pair of newborn rabbits (one male and one female) is kept on an island where there are
no other rabbits. A pair of rabbits does not breed until they are two months old. After a
pair becomes two months old, each pair of rabbits (of opposite sexes) produce another pair (of
opposite sexes) each month. Assuming that no rabbits ever die, nd a recurrence relation for
the number of pairs of rabbits on the island just after n months.
Solution. Let a
n
denote the number of pairs of rabbits on the island just after n months. At
the end of the rst moth, the number of pairs of rabbits on the island is
a
1
= 1
This pair of rabbits does not breed during the second month. Thus, the number of pairs of
rabbits just after the second month is
a
2
= 1.
Now the number of pairs of rabbits, a
n
, just after n months is the number of pairs after n 1
months plus the number of newborn pairs in the nth month. The number of newborn pairs
in the nth month is the number of pairs just after the (n 2)th month because each newborn
pair is produced by a pair of rabbits at least two months old. Hence,
a
n
= a
n1
+a
n2
, n 3.
which is a recurrence relation. The initial condition are a
1
= 1 and a
2
= 1. Now
a
3
= a
2
+a
1
= 1 + 1 = 2,
a
4
= a
3
+a
2
= 2 + 1 = 3,
a
5
= a 4 +a
3
= 3 + 2 = 5,
and so on. We see that the sequence dened above is
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,
which is the Fibonacci Sequence.
4.2 Solving Recurrence relations by Iterations (Substitution)
Our goal in solving a recurrence relation is to nd an explicit formula for the general term
a
n
of the recurrence relation. In this section, we describe how to nd an explicit formula by
iteration, or substitution.
4.2 Solving Recurrence relations by Iterations (Substitution) 31
Suppose a recurrence relation for a sequence a
0
, a
1
, a
2
, , a
n
, , is given. By a solu-
tion of the recurrence relation we mean to obtain an explicit formula for a
n
, i.e., to nd
an expression for a
n
that does not involve any other a
i
, i = n 1, n 2, .
When the problem is to nd an explicit formula for a recursively dened sequence, the recur-
sive formula is called a recurrence relation. Remember that to dene a sequence recurssively,
a recursive formula must be accompanied by information about the beginning of the sequence.
This information is called the initial condition or conditions for the sequence.
(a). The recurrence relation a
n
= a
n1
+ 3 with a
1
= 4 recursively denes the sequence
4, 7, 10, 13, .
(b). The recurrence relation f
n
= f
n1
+f
n2
, f
1
= f
2
= 1 denes the Fibonacci sequence
1, 1, 2, 3, 5, 8, 13, 21, .
The initial conditions are f
1
= 1 and f
2
= 1.
Recurrence relations arise naturally in many counting problems and in analyzing programming
problems.
Example 4.2.1. The recurrence relation a
n
= a
n1
+ 3 with a
1
= 2 denes the sequence
2, 5, 8, . We backtrack the value of a
n
b ysubstituting the denition of a
n1
, a
n2
, and so
on until a pattern is clear,
a
n
= a
n1
+ 3
= (a
n2
+ 3) + 3 = a
n2
+ 2 3
= ((a
n3
+ 3) + 3) + 3 = a
n3
+ 3 3
Eventually this process will produce
a
n
= a
n(n1)
+ (n 1) 3
= a
1
+ (n 1) 3
= 2 + (n 1) 3
An explicit formula for the sequence is
a
n
= 2 + (n 1)3
Example 4.2.2. Let S be the sequence a
n

n=0
, where a
n
= 7a
n1
6a
n2
for all n 2.
Because a
n
is dened in terms of the preceding terms a
n1
and a
n2
, the equation above is a
recurrence relation.
Let us show that a
n
= 5 = 5 + 0 n is a solution of the equation above. Here a
0
= 5,
a
1
= 5, a
2
= 5, , a
n
= 5, and so on. Let us evaluate the RHS of the equation, i.e.,
7a
n1
6a
n2
= 7 5 6 5 = 35 30 = 5 = a
5
Hence a
n
= 5, n 0 is a solution of the recurrence relation above.
Example 4.2.3. Backtrack to nd an explicit formula for the sequence dened by the recur-
rence relation
b
n
= 2b
n1
+ 1 with initial condition b
1
= 7.
4.2 Solving Recurrence relations by Iterations (Substitution) 32
Solution. We begin b ysubstituting the denition of the previous term in the dening formula
b
n
= 2b
n1
+ 1
= 2(2b
n2
+ 1) + 1
= 2[2(2b
n3
+ 1) + 1] + 1
= 2
3
b
n3
+ 4 + 2 + 1
= 2
3
b
n3
+ 2
2
+ 2
1
+ 1.
A pattern is emerging with these rewrittings of b
n
. (Note: There are no set rules for how to
rewrite these expressions and a certain amount of experimentation may be necessary.)
The backtesting will end at
b
n
= 2
n1
b
n(n1)
+ 2
n2
+ 2
n3
+ + 2
2
+ 2
1
+ 1
= 2
n1
b
1
+ 2
n1
1 (using mathematical induction)
1 + 2
1
+ 2
2
+ + 2
n
= 2
n+1
1.
= 7 2
n1
+ 2
n1
1 using b
1
= 7
= 8 2
n1
1 or 2
n+2
1.
Recall the following
1 +a +a
2
+a
3
+ +a
n1
=
a
n
1
a 1
1 + 2 + 3 + +n =
n(n + 1)
2
Backtracking may not reveal an explict pattern for the sequence dened a recurrence rela-
tion. We now introduce a more general technique for solving a recurrence relation. First we
give a denition. A recurrence realtion is a linear homogeneous relation of degree k if it
is of the form
a
n
= r
1
a
n1
+r
2
a
n2
+ +r
k
a
nk
with the r
i
s constants.
Note that on the right-hand side, the summands are each built the same (homogeneeous) way,
as a multiple of one of the k (degree k) previuos terms (linear).
Example 4.2.4. Consider the following;
(a). The relation c
n
= (2)c
n1
is a linear homogeneous recurrence relation of degree 1.
(b). The relation a
n
= a
n1
+ 3 is not a linear homogeneous recurrence relation.
(c). The recurrence relation f
n
= f
n1
+f
n2
is a linear homogeneous relation of degree 2.
(d). The recurrence relation a
n
= a
2
n1
+a
n2
is not a linear homogeneous relation.
For a linear homogeneous recurrence relation of degree k, a
n
= r
1
a
n1
+ r
2
a
n2
+ +
r
k
a
nk
, we call the associated polynomial of degree k, x
k
= r
1
x
k1
+ r
2
x
k2
+ + r
k
its
characteristic equation. The roots of the characteristic equation play a key role in the
explicit formula for the sequence dened by the recurrence relation and the initial conditions.
While the problem can be solved in general, we give a theorem for degree 2 only. Here it is
common to write the characteristic equation as x
2
r
1
x r
2
= 0.

Potrebbero piacerti anche