Module IT2012PD (1)(3)
Module IT2012PD (1)(3)
Module On
i
Table of Contents --------------------------------------------------------------------- i
Contents Pages
Aim ------------------------------------------------------------------------------------------------------------------1
Description ---------------------------------------------------------------------------------------------------------1
Objectives ----------------------------------------------------------------------------------------------------------1
Chapter 1: Elementary counting principles --------------------------------------------------------------- 2
1.1 Basic counting principle ------------------------------------------------------------------------------2
1.2 Permutations and combinations --------------------------------------------------------------------- 8
1.3 The Binomial Theorem -------------------------------------------------------------------------------14
1.4 The Inclusion-Exclusion principles ---------------------------------------------------------------- 19
1.5 The Pigeonhole principle ---------------------------------------------------------------------------- 20
Chapter 2: Recurrence relations ---------------------------------------------------------------------------- 26
2.1 Definition and examples of recurrence relations -------------------------------------------------- 26
2.2 Solving linear recurrence relations (homogeneous and non-homogeneous) ------------------- 32
2.3 Generating functions ----------------------------------------------------------------------------------- 41
Chapter 3: Elements of graph theory ---------------------------------------------------------------------- 55
3.1 Definitions of terms of graphs and types of graphs ------------------------------------------------ 55
3.2 Isomorphism of graphs and matrix representation of a graphs ---------------------------------- 64
3.3 Path and connectivity of a graph ----------------------------------------------------------------------70
3.4 Eulerian and Hamiltonian graphs ---------------------------------------------------------------------78
3.5 Planar graphs -------------------------------------------------------------------------------------------- 80
3.6 Trees and forests ---------------------------------------------------------------------------------------- 82
3.7 Graph Coloring ------------------------------------------------------------------------------------------ 90
3.8 Directed graphs ------------------------------------------------------------------------------------------ 93
Chapter 4: Weighted graphs and Their applications ---------------------------------------------------- 104
4.1 Definition and examples of Weighted Graphs ----------------------------------------------------- 104
4.2 Minimal Spanning trees ------------------------------------------------------------------------------- 105
4.3 Shortest path problem -----------------------------------------------------------------------------------110
Chapter 5: Networks and Flows ------------------------------------------------------------------------------ 119
5.1 Definition and Examples of Network and flow ------------------------------------------------------ 119
5.2 The max-flow and min-cut ------------------------------------------------------------------------------ 121
Reference -----------------------------------------------------------------------------------------------------------126
i
Discrete Mathematics & Combinatorics
3
Discrete Mathematics & Combinatorics
Chapter One
Elementary Counting Principle
Introduction
Suppose that a password on a computer system consists of six, seven, or eight characters. Each of
these characters must be a digit or a letter of the alphabet. Each password must contain at least one
digit. How many such passwords are there? The techniques needed to answer this question and a
wide variety of other counting problems will be introduced in this section. Counting problems arise
throughout mathematics and computer science. For example, we must count the successful
outcomes of experiments and all the possible outcomes of these experiments to determine
probabilities of discrete events. We need to count the number of operations used by an algorithm
to study its time complexity.
We will introduce the basic techniques of counting in this section. These methods serve as the
foundation for almost all counting techniques.
Chapter Objectives
On completion of this chapter, students will be able to:
Understand the basic counting principles.
Understand permutations and combinations.
Apply basic counting principles to solve counting problems.
Apply counting techniques to solve problems related with permutations and combinations.
Understand the inclusion – exclusion principle.
Understand the pigeonhole principle.
4
Discrete Mathematics & Combinatorics
I. Addition Principle:
If E1, E2 , … , En are mutually exclusive events and E1 can happen e1 ways , E2 can happen e2 ways ,
… , En can happen en ways , then E1 or E2 ,or … , or En can happen e1+ e2 + ….+ en ways.
In terms of set addition principle is stated as: Suppose that a set S is partitioned into pairwise
disjoint parts S1,S2 , ... ,Sm . The number of objects in S can be determined by finding the number
of objects in each of the parts, and adding the numbers so obtained:
If the sets S1, S2 ,… , Sm are allowed to overlap, then a more profound principle, the inclusion-
exclusion principle in the next section, can be used to count the number of objects in S.
Example 1: A student wishes to take either a mathematics course or a biology course, but not both.
If there are four mathematics courses and three biology courses for which the student has the
necessary prerequisites, then the student can choose a course to take in 4 + 3 = 7 ways.
Example 2: In how many ways can we get a sum of 4 or of 8 when two distinguishable dice are
rolled?
Solution: Let denote the possible outcomes obtained from rolling the dice by order pair (a , b)
where a and b are numbers from 1 to 6 on both dice with a+b = 4 or a +b = 8. Then the possible
outcomes to get sum of 4 are (1, 3) , (2 ,2) and (3, 1), implies that there are e1= 3 ways to obtain
the sum 4 (E1).
And also we obtain the sum 8 (E2) from the outcomes (2, 6) , (3,5) , (4, 4) , (5, 3) and (6, 2).
Here e2 =5 ways. Therefore there are 3+5 = 8 ways to get the sum of 4 or 8.
Example 3: A student can choose a computer project from one of three lists. The three lists contain
23, 15 and 19 possible projects, respectively. No project is on more than one list. How many
possible projects are there to choose from?
Solution: The student can choose a project by selecting a project from the first list, the second list,
or the third list. Because no project is on more than one list, by the addition principle there are 23
+ 15 + 19 = 57 ways to choose a project.
Example 4: In how many ways can we draw a heart or a spade from an ordinary deck of playing
cards? A heart or an ace? An ace or a king? A card numbered 2 through 10? A numbered card or
a king?
5
Discrete Mathematics & Combinatorics
Solution. Since there are 13 hearts and 13 spades we may draw a heart or a spade in
13 + 13 = 26 ways.
We may draw a heart or an ace in 13 + 3 = 16 ways, since there are only 3 aces that are not hearts.
We may draw an ace or a king in 4 + 4 = 8 ways.
These are 9 cards numbered 2 through 10 in each of 4 suits, clubs, diamonds, hearts, or spades.
So we may choose a numbered card in 36 ways.
Thus, we may choose a numbered card or a king in 36 + 4 = 40 ways.
Example 5: How many ways can we get a sum of 8 when two indistinguishable dice are rolled?
An even sum?
Solution: Had the dice been distinguishable, we should obtain a sum of 8 by the outcomes (2,
6), (3, 5), (4, 4), (5, 3) and (6, 2), but since the dice are similar, the outcomes (2, 6) and (6, 2) and,
as well, (3, 5) and (5, 3) cannot be differentiated and thus we obtain the sum of 8 with the roll of
two similar dice in only 3 ways. Likewise, we can get an even sum in 1 + 2 + 3 + 3 + 2 + 1 = 12
ways.
Example 6: If there are 14 boys and 12 girls in a class, find the number of ways of selecting one
student as class representative.
Solution: Using sum rule, there are 14 + 12 = 26 ways of selecting one student (either a boy or a
girl) as class representative.
NB. The Multiplication Principle applies when a procedure is made up of separate tasks.
Example 1: How many two letter words start with one of the 5 vowels?
Solution: There are 26 two letter words starting with A, another 26 starting with E, and so on.
We will have 5 groups of 26. So we add 26 to itself 5 times. Of course it would be easier to just
multiply 5 · 26.
Example 2: If 2 distinguishable dice are rolled, in how many ways can they fall? If 5
distinguishable dice are rolled, how many possible outcomes are there?
6
Discrete Mathematics & Combinatorics
Solution: The first die can fall (event E1) in 6 ways and the second can fall (event E2) in 6 ways.
There are 6.6 = 62 = 36 outcomes are rolled dice when 2 dice are rolled. And there are 6.6.6.6.6.6
= 65 possible outcome when 5 dice are rolled.
Example 3: There are 32 microcomputers in a computer center. Each microcomputer has 24 ports.
How many different ports to a microcomputer in the center are there?
Solution: The procedure of choosing a port consists of two tasks, first picking a microcomputer
and then picking a port on this microcomputer. Because there are 32 ways to choose the
microcomputer and 24 ways to choose the port no matter which microcomputer has been selected,
the product rule shows that there are 32 · 24 = 768 ports.
Example 4: How many different license plates can be made if each plate contains a sequence of
three uppercase English letters followed by three digits (and no sequences of letters are prohibited,
even if they are obscene)?
Solution: There are 26 choices for each of the three uppercase English letters and ten choices for
each of the three digits. Hence, by the product rule there are a total of 26 · 26 · 26 · 10 · 10 · 10 =
17,576,000 possible license plates.
Example 5: The number of ways a man, woman, boy, and girl can be selected from five men, six
women, two boys, and four girls is 5 x 6 x 2 x 4 = 240.
Example 6: How many two-digit numbers have distinct and nonzero digits? A two-digit number
ab can be regarded as an ordered pair (a, b), where a is the tens digit and b is the units digit. Neither
of these digits is allowed to be 0 in the problem, and the two digits are to be different. There are
nine choices for a, namely 1,2, ... ,9. Once a is chosen, there are eight choices for b. If a = 1, these
eight choices are 2,3, ... ,9, if a = 2, the eight choices are 1,3, ... ,9, and so on. What is important
for application of the multiplication principle is that the number of choices is always 8. The answer
to the questions is, by the multiplication principle, 9 x 8 = 72. We can arrive at the answer 72 in
another way. There are 90 two-digit numbers, 10,11,12, ... ,99. Of these numbers, nine have a 0,
(namely, 10,20, ... , 90) and nine have identical digits (namely, 11,22, ... ,99). Thus the number of
two-digit numbers with distinct and nonzero digits equals 90 - 9 - 9 = 72.
Example 7: Each user on a computer system has a password, which is six to eight characters long,
where each character is an upper case letter or a digit. Each password must contain at least one
digit. How many possible passwords are there?
7
Discrete Mathematics & Combinatorics
Solution: Let P be the total number of possible passwords, and let P6, P7 and P8 denote the number
of possible passwords of length 6, 7, and 8 respectively.
By the sum rule, P = P6 + P7 + P8
We will now find P6, P7, and P8. Finding P6 directly is difficult.
To find P6 it is easier to find the number of strings of upper case letters and digits that are six
characters long, including those with no digits, and subtract from this the number of strings with
no digits.
By the product rule, the number of strings of six characters is 366 and the number of strings with
no digits is 266.
Hence, P6 = 366 – 266 = 2, 176, 782, 336 – 308, 915, 776
= 1, 867, 866, 560.
Similarly, it can be shown that
P7 = 367 – 267 = 78, 364, 164, 096 – 8, 031, 810, 176
= 70, 332, 353, 920.
and P8 = 368 – 268 = 2, 821, 109, 907, 456 – 208, 827, 064, 576
= 2, 612, 282, 842, 880.
Consequently,
P = P6 + P7 + P8
= 2, 684, 483, 063, 360.
Example 8:
a) How many 2 digit or 3-digit numbers can be formed using the digits 1, 3, 4, 5, 6, 8 and 9 if
no repetition is allowed ?
b) How many numbers can be formed using the digits 1, 3, 4, 5, 6, 8 and 9 if no repetition are
allowed?
Solution:
a) There are 7.6.5, three-digit numbers possible. Likewise, we can apply the product rule to see
that these are 7.6 possible 2-digit numbers.
Hence, these are 7.6 + 7.6.5 possible two-digit or three-digit numbers.
b) The number of digits are not specified in this problem so we can form one-digit numbers, two-
digit numbers, or three digit numbers, etc.
8
Discrete Mathematics & Combinatorics
But since no repetitions are allowed and we have only the 7 integers to work with, the maximum
number of digits would have to be 7.
Applying the product rule, we see that we may form 7 one-digit numbers, 7.6 = 42 two digit
numbers 7.6.5 three digit numbers, 7.6.5.4 four digit numbers, 7.6.5.4.3 five digit numbers,
7.6.5.4.3.2 six-digit numbers, and 7.6.5.4.3.2.1 seven-digit numbers.
The events of forming one-digit numbers, two digit numbers, three digit numbers, etc., are
mutually exclusive events so,
We apply the sum rule to see that there are
7 + 7.6 + 7.6.5 + 7.6.5.4 + 7.6.5.4.3 + 7.6.5.4.3.2 + 7.6 + 7.6.5.4.3.2.1 = 13, 741
different numbers we can form under the restrictions of this problem.
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
1. State addition principle.
2. State multiplication principle.
3. Solve problems given this subtopics related to addition and
multiplication principles.
Is your response positive for the above questions? If your answer is “I Can”, go to the next
section. If your answer is “I Can’t”, go back and read once again.
Exercise 1.1
1.
Ways to travel from C to D, how many ways are there to travel from A to D?
2. Suppose repetitions are not permitted.
a) Find the number of three-digit numbers that can be formed from the six digits 2,
3, 5, 6, 7, and 9.
b) How many of them are less than 400?
c) How many of them are even?
9
Discrete Mathematics & Combinatorics
3. A Mathematics class contains 8 male students and 6 female students. Find the number n of
ways that the class can elect:
a) 1 class representative
b) 2 class representatives, 1 male and 1 female
c) 1 president and 1 vice president.
4. How many license plates consisting of 2 nonrepeating letters (A to Z) followed by 3 even
digits (0 to 8) are possible?
5. How many 6-digit numbers have odd digits in the odd places and even digits in the even
places?
6. A certain Internet provider requires that its e-mail addresses consist of 6 characters (letters
A to Z or digits 0 to 9). Further, the first character must be a letter, and the last character
must be a digit. How many different e-mail accounts are possible from this provider?
7. How many 5-digit numbers neither start with zero nor end in zero?
8. How many 6-digit numbers (leading zeros are allowed) have the last two digits the same as
the first two digits (in the same order)?
10
Discrete Mathematics & Combinatorics
Many counting problems can be thought of as a selection of some objects from a fixed set of
objects. In some cases, the order in which the objects are selected is important, and in others it is
not. As we shall see, permutations handle the former case, and combinations handle the latter.
Definition: A permutation of r objects from a set of size n is an ordered list of r of the n objects.
An r-permutation is an ordered arrangement of r elements of a set.
Example 1: Consider the set of letters A, B, C, D. Then:
i) BDCA, DCBA, and ACDB are permutations of the four letters (taken all at a time).
ii) BAD, ACB, DBC are permutations of the four letters taken three at a time.
iii) AD, BC, CA are permutations of the four letters taken two at a time.
Example 2: If S = {A, B, C, D, E} is the set of n = 5 objects under consideration and r = 3,
then all of the possible permutations of 3 elements from S are listed below.
ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE
ACB ADB AEB ADC AEC AED BDC BEC BED CED
BAC BAD BAE CAD CAE DAE CBD CBE DBE DCE
BCA BDA BEA CDA CEA DEA CDB CEB DEB DEC
CAB DAB EAB DAC EAC EAD DBC EBC EBD ECD
CBA DBA EBA DCA ECA EDA DCB ECB EDB EDC
They are 60 in number.
Example 3: In how many ways can we arrange three students from a group of five students to
stand in line for a picture? In how many ways can we arrange all five of these students in a line for
a picture?
Solution: There are five ways to take the first student to stand at the start of the line. Once this
student has been taken, there are four ways to take the second student in the line. After the first
and second students have been taken, there are three ways to take the third student in the line.
There are 5.4.3 = 60 ways to arrange three students from a group of five students to stand in line
for a picture.
To arrange all five students in a line for a picture, we take the first student in five ways, the second
in four ways, the third in three ways, the fourth in two ways, and the fifth in one way.
Consequently, there are 5 · 4 · 3 · 2 · 1 = 120 ways to arrange all five students in a line for a
picture.
11
Discrete Mathematics & Combinatorics
Example 4: Let S = {a, b, c}. The 2-permutations of S are the ordered arrangements ab, ac, ba,
bc, ca, cb. Consequently, there are 6 2-permutations of this set with three elements.
Theorem 1. If n is a positive integer and r is an integer with 1 ≤ r ≤ n, then there are
P (n, r) = n(n − 1)(n − 2) · · · (n − r + 1)
r-permutations of a set with n distinct elements.
Corollary 1. If n and r are integers with 0 ≤ r ≤ n, then
𝑛!
𝑃(𝑛, 𝑟) = (𝑛−𝑟)!
Example 5: How many ways are there to select a first-prize winner, a second-prize winner, and a
third-prize winner from 100 different people who have entered a contest?
Solution: Because it matters which person wins which prize, the number of ways to pick the three
prize winners is the number of ordered selections of three elements from a set of 100 elements,
that is, the number of 3 permutations of a set of 100 elements. Consequently, the answer is
P(100, 3) = 100 · 99 · 98 = 970,200.
Example 6: Suppose that there are eight runners in a race. The winner receives a gold medal, the
second place finisher receives a silver medal, and the third-place finisher receives a bronze medal.
How many different ways are there to award these medals, if all possible outcomes of the race can
occur and there are no ties?
Solution: The number of different ways to award the medals is the number of 3-permutations
of a set with eight elements. Hence, there are P(8, 3) = 8 · 7 · 6 = 336 possible ways to award
the medals.
Example 7: The number of four-letter "words" that can be formed by using each of the letters a,
b, c, d, e at most once is P(5,4), and this equals 5!/(5 - 4)! = 120. The number of five-letter words
equals P(5, 5), which is also 120.
Example 8: What is the number of ways to order the 26 letters of the alphabet so that no two of
the vowels a, e, i, o, and u occur consecutively?
Solution: Here we think of two main tasks to be accomplished. The first task is to decide how to
order the consonants among themselves. There are 21 consonants, and so 21! permutations of the
consonants. Since we cannot have two consecutive vowels in our final arrangement, the vowels
must be in 5 of the 22 spaces before, between, and after the consonants. Our second task is to put
the vowels in these places. There are 22 places for the a, then 21 for the e, 20 for the i, 19 for the
o, and 18 for the u. That is, the second task can be accomplished in
12
Discrete Mathematics & Combinatorics
ways. By the multiplication principle, we determine that the number of ordered arrangements
of the letters of the alphabet with no two vowels consecutive is
Example 10: Find the number of 3- permutations of the letters p , q , r , s and t in circle.
Solution: n = 5 and r = 3, the using the above formula,
𝑛! 5!
= = 20.
𝑟(𝑛−𝑟)! 3(5−3)!
Example:
13
Discrete Mathematics & Combinatorics
Example 12: In how many ways can the letters of the English alphabet be arranged so that there
are exactly ten letters between a and z?
Solution. There are P(24, 10) arrangements of the letters of the alphabet (excluding a and z) taken
ten at a time, and hence 2.P(24, 10) strings of 12 letters, each beginning and ending with an a and
z (either letter coming first in a string).
For each of these strings, there are 15! ways to arrange the 14 remaining letters and the string.
So there are altogether
2.P(24, 10) . 15! arrangements of the desired type.
Example 13: A man, a woman, a boy, a girl, a dog, and a cat are walking down a long and
winding road one after the other.
a) In how many ways can this happen?
b) In how many ways can this happen if the dog comes first?
c) In how many ways can this happen if the dog immediately follows the boy?
d) In how many ways can this happen if the dog (and only the dog) is between the man and
the boy?
Solution: a) There are 6! = 720 ways for six creatures to form a line.
b) If the dog comes first, the others can form = 5! lines behind.
c) If the dog immediately follows the boy, then the dog-boy pair should be thought of
as a single object to be put into a line with four others.
There are 5! = 120 such lines.
d) If the man, dog, and boy appear in this order, then thinking of man-dog-boy as a
e) single object to be put into a line with three others, we see that there are 4!
possible lines. Similarly, there are 4! lines in which the boy, dog, and man appear
in this order.
So, by the addition rule, there are 4! + 4! = 48 lines in which the dog (and only the
dog) is between the man and the boy.
Example 14: Find the number of positive integers greater than a million that can be formed with
the digits 2, 3, 0, 3, 4, 2 and 3.
14
Discrete Mathematics & Combinatorics
The set of these 420 positive integers, include some numbers which begin with 0.
Clearly, these numbers are less than a million and they must not be counted in our answer.
The number of such numbers is given by the permutations of 6 non-zero digits and is equal to
Therefore, the number of positive integers greater than a million that can be formed with given
digits is equal to 420 – 60 = 360.
Example 15: In how many different ways can 5 men and 5 women sit around a table, if
i) there is no restriction
ii) no two women sit together?
Solution: i) The problem is related to circular permutation of 10 objects (5 men and 5 women). If
there is no restriction then the number of permutations is (10 – 1)! = 9! = 362880.
Notice here the difference in arrangement between clockwise and anticlockwise.
ii) there is a restriction that no two women are allowed to sit side by side. To meet this
restriction each woman should occupy a sit between two men.
The number of ways five men can sit around a table is 4! = 24.
Once these five men have sat on alternate chairs, the five women can occupy the 5 empty chairs
in 5! ways.
Thus, total number of ways, in this case is 24 * 5! = 24 * 120 = 2880.
Definition: A combination of r elements from a set of size n is a subset of size r. An r-
combination of elements of a set is an unordered selection of r elements from the set of n
elements.
Example 1: If S = {a, b, c, d, e} is the set of n = 5 objects under consideration and r = 3, then all
of the possible combinations of 3 elements from S are listed below.
{a, b, c} {a, b, d} {a, b, e} {a, c, d} {a, c, e}
{a, d, e} {b, c, d} {b, c, e} {b, d, e} {c, d, e}
15
Discrete Mathematics & Combinatorics
Example 2: Let S be the set {1, 2, 3, 4}. Then {1, 3, 4} is a 3-combination from S. Note that {4,
1, 3} is the same 3-combination as {1, 3, 4}, because the order in which the elements of a set are
listed does not matter.
Example 3: The 2-combinations of {a, b, c, d} are the six subsets {a, b},{a, c}, {a, d}, {b, c}, {b,
d}, and {c, d}.
Theorem 2: The number of r-combinations of a set with n elements, where n is a nonnegative
integer and r is an integer with 0 ≤ r ≤ n, is given by
𝑛!
𝐶(𝑛, 𝑟) = 𝑟! (𝑛 − 𝑟)!
by Multiplication principle.
Corollary 2: Let n and r be nonnegative integers with r ≤ n. Then
𝐶(𝑛, 𝑟) = 𝐶(𝑛, 𝑛 − 𝑟).
16
Discrete Mathematics & Combinatorics
17
Discrete Mathematics & Combinatorics
𝑛 𝑛−1 𝑛−1
( )=( )+( )
𝑟 𝑟−1 𝑟
0
( ) … n=0
0
1 1
( ) ( ) … n=1
0 1
2 2 2
( ) ( ) ( ) … n=2
0 1 2
3 3 3 3
( ) ( ) ( ) ( ) … n=3
0 1 2 3
Example 1:
Solution: Here, the sum in our expansion is indexed over the triples
18
Discrete Mathematics & Combinatorics
Solution:
In many counting problems, elements may be used repeatedly. For instance, a letter or digit may
be used more than once on a license plate. When a dozen donuts are selected, each variety can be
chosen repeatedly. This contrasts with the counting problems discussed earlier in the chapter where
we considered only permutations and combinations in which each item could be used at most once.
In this section we will show how to solve counting problems where elements may be used more
than once.
Also, some counting problems involve indistinguishable elements. For instance, to count the
number of ways the letters of the word SUCCESS can be rearranged, the placement of identical
letters must be considered. This contrasts with the counting problems discussed earlier where all
elements were considered distinguishable. In this section we will describe how to solve counting
problems in which some elements are indistinguishable.
19
Discrete Mathematics & Combinatorics
Counting permutations when repetition of elements is allowed can easily be done using the
product rule, look example below.
Example: 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.
Theorem 6: The number of r-permutations of a set of n objects with repetition allowed is given
by
𝑈(𝑛, 𝑟) = 𝑛𝑟
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 multiplication principle there are 𝑛𝑟 r-permutations when repetition is allowed.
Example 1: Find the number of words that can be formed using the letters of the word
“BENZENE.”
Solution:
Example: Find the number of mathematics students at a college taking at least one of the
languages French, German, and Russian, given the following data:
65 study French, 20 study French and German,
45 study German, 25 study French and Russian,
42 study Russian, 15 study German and Russian,
and 8 study all three languages.
21
Discrete Mathematics & Combinatorics
We want to find n(F ∪ G ∪ R) where F, G, and R denote the sets of students studying French,
German, and Russian, respectively.
By the Inclusion–Exclusion Principle,
n(F ∪ G ∪ R )= n(F ) + n(G) + n(R) − n(F ∩ G) − n(F ∩ R) − n(G ∩ R) + n(F ∩ G ∩ R)
= 65 + 45 + 42 − 20 − 25 − 15 + 8 = 100
This implies, 100 students study at least one of the three languages.
Example 1: Suppose a department contains 13 professors, then two of the professors were born
in the same month. Because there are 12 months in a year.
Example 2: There are n married couples. How many of the 2n people must be selected to
guarantee that a married couple has been selected?
Solution. To apply the pigeonhole principle in this case, think of n boxes, one corresponding
to each of the n couples. If we select n + 1 people and put each of them in the box corresponding
to the couple to which they belong, then some box contains two people; that is, we have selected
a married couple. Two of the ways to select n people without getting a married couple are to
select all the husbands or all the wives.
Therefore, n + 1 is the smallest number that will guarantee a married couple has been selected.
Example 3: Find the minimum number of elements that one needs to take from the set S = {1, 2,
3, . . . , 9} to be sure that two of the numbers add up to 10.
Here the pigeonholes are the five sets {1, 9}, {2, 8}, {3, 7}, {4, 6}, {5}. Thus any choice of six
elements of S will guarantee that two of the numbers add up to ten.
22
Discrete Mathematics & Combinatorics
Example 1: Find the minimum number of students in a class to be sure that three of them are
born in the same month.
Solution: the number of months on one year is k = 12. Then the required minimum number of
students in a class is equal to 2(12) + 1 = 24 + 1 = 25.
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
1. Define permutation and combination.
2. List r – permutations and r – combinations of n distinct objects.
3. Evaluate the number of r – permutations and r – combinations of n
distinct objects.
4. Solve problems related to permutations and combinations.
5. State inclusion – exclusion principle.
6. State pigeonhole principle.
7. Solve problems related to inclusion – exclusion principle and
pigeonhole principle.
Is your response positive for the above questions? If your answer is “I Can”, go to the next
section. If your answer is “I Can’t”, go back and read once again.
Exercise 1.2
1. List all the permutations of {a, b, c}.
2. How many different permutations are there of the set {a, b, c, d, e, f, g}
3. How many permutations of {a, b, c, d, e, f, g} end with a?
4. Let S = {1, 2, 3, 4, 5}
a) List all the 3-permutations of S.
b) List all the 3-combinations of S.
5. Find the value of each of these quantities.
23
Discrete Mathematics & Combinatorics
a) P(6, 3) b) P(6, 5)
6. Find the value of each of these quantities.
a) C(5, 1) b) C(5, 3)
7. Find the number of 5-permutations of a set with nine elements.
8. A class contains 10 students with 6 men and 4 women. Find the number of ways to:
a) Select a 4 member committee from the students.
b) Select a 4 member committee with 2 men and 2 women.
9. Find n if
a) P(n, 2) = 110.
b) P(n, n) = 5040.
c) P(n, 4) = 12P(n, 2).
d) C(n, 2) = 45.
e) C(n, 3) = P(n, 2).
f) C(n, 5) = C(n, 2).
10. How many integers greater than 5400 have both of the following properties?
(a) The digits are distinct.
(b) The digits 2 and 7 do not occur.
11. In how many ways can four men and eight women be seated at a round table if there are to
be two women between consecutive men around the table?
12. In how many ways can six men and six women be seated at a round table if the men and
women are to sit in alternate seats?
13. In how many ways can 15 people be seated at a round table if B refuses to sit next to A?
What if B only refuses to sit on A's right?
14. Consider all 5 letter “words” made from the letters a through h. (Recall, words are just
strings of letters, not necessarily actual English words.)
(a) How many of these words are there total?
(b) How many of these words contain no repeated letters?
(c) How many of these words start with the sub-word “aha”?
(d) How many of these words either start with “aha” or end with “bah” or both?
(e) How many of the words containing no repeats also do not contain the sub-word “bad”?
15. Let S = {1, 2, 3, 4, 5, 6}
24
Discrete Mathematics & Combinatorics
21.
b) c)
22. What is the coefficient of x4y 6z2w4 in the expansion of (w − z + y − x)20?
23. What is the coefficient of x4y2z5w3 3 in the expansion of (x + y − 2z + w)14?
Review Exercise
1. In how many different orders can five runners finish a race if no ties are allowed?
2. How many possibilities are there for the win, place, and show (first, second, and third)
positions in a horse race with 12 horses if all orders of finish are possible?
3. Find the number of automobile license plates where
a) Each plate contains 2 different letters followed by 3 different digits.
b) The first digit cannot be 0.
4. A class has 10 male students and 8 female students. Find the number of ways the class can elect
a) a class representative
b) 2 class representatives, one male and one female
c) a class president and vice president.
5. Suppose a code consists of five characters, two letters followed by three digits. Find the number of: (a)
codes; (b) codes with distinct letter; (c) codes with the same letters.
25
Discrete Mathematics & Combinatorics
6. A class contains 9 men and 3 women. Find the number of ways a teacher can select a committee
of 4 from the class where there is:
a) no restrictions b) 2 men and 2 women c) exactly one woman d) at least one woman.
7. There are six different candidates for governor of a state. In how many different orders can the
names of the candidates be printed on a ballot?
8. How many bit strings of length 10 contain
a) exactly four 1s?
b) at most four 1s?
c) at least four 1s?
d) an equal number of 0s and 1s?
9. A group contains n men and n women. How many ways are there to arrange these people in a
row if the men and women alternate?
10. In how many ways can a set of two positive integers less than 100 be chosen?
11. In how many ways can a set of five letters be selected from the English alphabet?
12. How many subsets with an odd number of elements does a set with 10 elements have?
13. How many subsets with more than two elements does a set with 100 elements have?
14. A coin is flipped eight times where each flip comes up either heads or tails. How many possible
outcomes
a) are there in total?
b) contain exactly three heads?
c) contain at least three heads?
d) contain the same number of heads and tails?
15. A coin is flipped 10 times where each flip comes up either heads or tails. How many possible
outcomes
a) are there in total?
b) contain exactly two heads?
c) contain at most three tails?
d) contain the same number of heads and tails?
16. Simplify
17.
26
Discrete Mathematics & Combinatorics
18. Find the minimum number of students needed to guarantee that five of them belong to the same
class (Freshman, Sophomore, Junior, Senior). Ans 17
19. Find the minimum number of students needed to guarantee that 3 of them:
a) have last names which begin with the same first letter;
b) were born on the same day of a month (with 31 days).
20. Find the number of permutations that can be formed from all the letters of each word:
a) QUEUE b) COMMITTEE c) PROPOSITION d) BASEBALL.
21. Suppose you have sets A and B with |A| = 10 and |B| = 15.
a) What is the largest possible value for |A ∩ B|?
b) What is the smallest possible value for |A ∩ B|?
c) What are the possible values for |A ∪ B|?
22. If |A| = 8 and |B| = 5, what is |A ∪ B| + |A ∩ B|?
27
Discrete Mathematics & Combinatorics
Chapter Two
Recurrence Relations
Chapter Objectives
On completion of this chapter, students will be able to
Introduction
Some of the counting problems that cannot be solved using the techniques discussed in chapter 1
can be solved by finding recurrence relations involving the terms of a sequence. In this section
we will study a variety of counting problems that can be modeled using recurrence relations. In
this section we will study methods for finding explicit formulae for the terms of sequences that
satisfy certain types of recurrence relations.
one or more of previous term 𝑎0 , 𝑎1 , …, 𝑎𝑛−1 for all 𝑛 ≥ 𝑛0 , where 𝑛0 is a non – negative integer.
Example 1: Consider the following sequence which begins with the number 3 and for which
each of the following terms is found by multiplying the previous term by 2:
3, 6, 12, 24, 48, . . .
It can be defined recursively by
a0 = 3, an= 2an-1 for n ≥1 or a0 = 3, an+1 = 2ak for n ≥ 0
28
Discrete Mathematics & Combinatorics
The second definition may be obtained from the first by setting n = n +1.
Clearly, the formula an = 3(2n) gives us the nth term of the sequence without calculating any
previous term.
The following remarks about the above example are in order.
1) The equation an = 2an-1 or, equivalently, an+1 = 2an, where one term of the sequence is
defined in terms of previous terms of the sequence, is called a recurrence relation.
2) The equation a0 = 3, which gives a specific value to one of the terms, is called an initial
condition.
3) The function an = 3(2n), which gives a formula for an as a function of n, not of previous
terms, is called a solution of the recurrence relation.
4) There may be many sequences which satisfy a given recurrence relation.
For example, each of the following is a solution of the recurrence relation
an = 2an -1.
1, 2, 4, 8, 16, . . . and 7, 14, 28, 56, 112, . . .
All such solutions form the so called general solution of the recurrence relation.
5) On the other hand, there may be only a unique solution to a recurrence relation which
also satisfies given initial conditions. For example, the initial condition a0 = 3 uniquely
yields the solution 3, 6, 12, 24, . . . of the recurrence relation an = 2an -1.
Example 2: Find a6 in the sequence defined by an = 2an-1 – an-2 with a0 = 3
and a1 = 4.
Solution. We know that a6 = 2a5 – a4. So to find a6 we need to find a5 and a4. Well
29
Discrete Mathematics & Combinatorics
Example 3: Find a recurrence relation and initial conditions for 1, 5, 17, 53, 161, 485 . . ..
Solution: Notice that these are growing by a factor of 3. i.e 1 · 3 = 3, 5 · 3 = 15, 17 · 3 = 51
and so on. It appears that we always end up with 2 less than the
next term.
So an = 3an-1 + 2 is our recurrence relation and the initial condition is a0 = 1.\
Example 4: A person invests 10,000 birr at 12% interest compounded annually. How much will
be there at the end of 15 years.
Solution: Let An represents the amount at the end of n years.
So at the end of n – 1 years, the amount is An-1.
Since the amount after n years equals the amount after n – 1 years plus interest for the nth year.
Thus the sequence {An} satisfies the recurrence relation
An = An-1 + (0.12) An-1 = (1.12) An-1, n ≥ 1.
With initial condition A0 = 10,000.
The recurrence relation with the initial condition allow us to compute the value of An for any n.
For example, A1 = (1.12) A0
A2 = (1.12) A1 = (1.12)2 A0
A3 = (1.12) A2 = (1.12)3A0
An = (1.12)n A0
which is an explicit formula and the required amount can be derived from the formula by putting
n = 15. So,
A15 = (1.12)15(10000).
Note: A sequence is solution of the recurrence relation if its terms satisfy the recurrence relation.
Example 4: Determine whether the sequences
a) an = 3n , n = 0 ,1 , 2, …
b) an = 2n , n = 0 ,1 , 2, …
30
Discrete Mathematics & Combinatorics
c) an = 5 , n = 0 ,1 , 2, …
is the solution of the recurrence relation an = 2an -1 - an-2 , n ≥2.
Thus, it is true.
Example 6: Find a recurrence relation and give initial conditions for the number of bit strings of
length n that do not have two consecutive 0s. How many such bit strings are there of length five?
Solution: Let 𝑎𝑛 denote the number of bit strings of length n that do not have two consecutive 0s.
To obtain a recurrence relation for 𝑎𝑛 , note that by the sum rule, the number of bit strings of length
n that do not have two consecutive 0s equals the number of such bit strings ending with a 0 plus
the number of such bit strings ending with a 1.We will assume that n ≥ 3, so that the bit string has
at least three bits.
The bit strings of length n ending with 1 that do not have two consecutive 0s are precisely the
bit strings of length n − 1 with no two consecutive 0s with a 1 added at the end. Consequently,
there are 𝑎𝑛−1 such bit strings. Bit strings of length n ending with a 0 that do not have two
consecutive 0s must have 1 as their (n − 1) bit; otherwise they would end with a pair of 0s. It
31
Discrete Mathematics & Combinatorics
follows that the bit strings of length n ending with a 0 that have no two consecutive 0s are precisely
the bit strings of length n − 2 with no two consecutive 0s with 10 added at the end. Consequently,
there are 𝑎𝑛−2 such bit strings.
We conclude that, 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 for n ≥ 3.The initial conditions are 𝑎1 = 2, 𝑎2 = 3 ,
To obtain a5, we use the recurrence relation three times to find that
a3 = a2 + a1 = 3 + 2 = 5,
a4 = a3 + a2 = 5 + 3 = 8,
a5 = a4 + a3 = 8 + 5 = 13.
32
Discrete Mathematics & Combinatorics
Example 2: The recurrence relation 𝑎𝑛 = 𝑎𝑛−1 2 + 𝑎𝑛−2 is not linear. The recurrence relation
ℎ𝑛 = 2ℎ𝑛−1 + 1 is not homogeneous. The recurrence relation 𝑎𝑛 = 𝑛𝑎𝑛−1 + 𝑎𝑛−2 does not have
constant coefficients.
Linear recurrence relations are studied for two reasons. First, they often occur in modeling of
problems. Second, they can be systematically solved.
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
1. Define recurrence relation for a sequence.
2. Derive recurrence relation for a sequence and from a given problem.
3. Check whether a given sequence is solution for a given recurrence
relation.
4. Find terms of a sequence from the given recurrence relation with
initial conditions.
5. Identify whether the given recurrence relation is linear recurrence
relation with constant coefficient.
Is your response positive for the above questions? If your answer is “I Can”, go to the next
section. If your answer is “I Can’t”, go back and read once again.
Exercise 2.1
1. Determine which of these linear homogeneous recurrence relations with constant coefficients
are. Also, find the degree of those that are.
2. Determine which of these linear homogeneous recurrence relations with constant coefficients
are. Also, find the degree of those that are.
33
Discrete Mathematics & Combinatorics
3. Show that the following sequences are solutions of the given recurrence relations.
a) an = 3(2n) ; an = 2an -1 for n ≥ 1, a0 = 3
b) an =3 · 2n − 2 · 3n ; an = 5an -1 − 6an - 2 for n ≥ 2, a0 = 1, a1 = 0
a) an = 6 · 2n − 2 · n2n ; an = 4an -1 − 4an - 2 for n ≥ 2, a0 = 6, a1 = 8
Solve the given linear recurrence relation with constant coefficients using different
methods.
Define generating function.
Find the generating function for a given sequence.
i) Characteristic roots method
The basic approach for solving linear homogeneous recurrence relations is to look for solutions
of the form 𝑎𝑛 = 𝑟 𝑛 , where r is a constant. Note that 𝑎𝑛 = 𝑟 𝑛 is a solution of the recurrence
relation 𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 if and only if
𝑟 𝑛 = 𝑐1 𝑟 𝑛−1 − c2 𝑟 𝑛−2 − . . . −𝑐𝑘 𝑟 𝑛−𝑘 .
When both sides of this equation are divided by 𝑟 𝑛−𝑘 and the right-hand side is subtracted from
the left, we obtain the equation 𝑟 𝑘 −𝑐1 𝑟 𝑘−1 − c2 𝑟 𝑘−2 − . . . −𝑐𝑘 = 0. Consequently, the sequence
{𝑎𝑛 } with 𝑎𝑛 = 𝑟 𝑛 is a solution if and only if r is a solution of this last equation. We call this the
characteristic equation of the recurrence relation. The solutions of this equation are called the
characteristic roots of the recurrence relation. As we will see, these characteristic roots can be used
to give an explicit formula for all the solutions of the recurrence relation.
Theorem 1: Let 𝑐1 and 𝑐2 be real numbers. Suppose that 𝑟 2 − 𝑐1 𝑟 − 𝑐2 = 0 has two distinct
roots 𝑟1and 𝑟2 . Then the sequence {𝑎𝑛 } is a solution of the recurrence relation 𝑎𝑛 = 𝑐1 𝑎𝑛−1 +
34
Discrete Mathematics & Combinatorics
35
Discrete Mathematics & Combinatorics
When these three simultaneous equations are solved for α1, α2, and α3, we find that α1 = 1,
α2= −1, and α3 = 2. Hence, the unique solution to this recurrence relation and the given initial
conditions is the sequence 𝑎𝑛 = 1 − 2𝑛 + 2. 3𝑛 .
Example 2: Suppose that the roots of the characteristic equation of a linear homogeneous
recurrence relation are 2, 2, 2, 5, 5, and 9 (that is, there are three roots, the root 2 with
multiplicity three, the root 5 with multiplicity two, and the root 9 with multiplicity one).What is
the form of the general solution?
Solution: The general form of the solution is
𝑎𝑛 = 𝛼1 2𝑛 + 𝛼2 𝑛2𝑛 + 𝛼3 𝑛2 2𝑛 + 𝛽1 5𝑛 + 𝛽2 𝑛5𝑛 + 𝜎9𝑛 .
Example 3: Find the solution to the recurrence relation an = −3an-1 − 3an-2 – an-3
with initial conditions a0 = 1, a1 = −2, and a2 = −1.
Solution: The characteristic equation of this recurrence relation is
𝑟 3 +3𝑟 2 + 3𝑟 + 1 = (r + 1)2 =0 , which implies there is a single root r = −1 of multiplicity 3 of
the characteristic equation. Then the solutions of this recurrence relation are of the form
𝑎𝑛 = 𝛼1 (−1)𝑛 + 𝛼2 𝑛(−1)𝑛 + 𝛼3 𝑛2 (−1)𝑛 .
To find the constants α1, α2, and α3, use the initial conditions. This gives
a0 = 1 = α1
a2 = −2 = −α1 – α2 – α3
a3 = −1 = α1+ 2α2 + 4α3
The simultaneous solution of these three equations is α1 = 1, α2= 3, and α3 = −2.
Therefore, the solution to this recurrence relation with the given initial conditions is the sequence
an = (1 + 3n − 2n2)(−1)n.
Linear Nonhomogeneous Recurrence Relations with Constant Coefficients
Definition: A linear nonhomogeneous recurrence relation with constant coefficients, that is, a
recurrence relation of the form
𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 + 𝑓(𝑛)
where c1, c2, . . . , ck are real numbers and f(n) is a function not identically zero depending
only on n. The recurrence relation 𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 is called the associated
homogeneous recurrence relation. It plays an important role in the solution of the
nonhomogeneous recurrence relation.
Example: Each of the recurrence relations an = an-1 + 2n, an = an-1 + an-2 + n2 + n + 1,
37
Discrete Mathematics & Combinatorics
an =3an-1 + n3n, and an = an-1 + an-2 + an-3 + n! is a linear nonhomogeneous recurrence relation
with constant coefficients. The associated linear homogeneous recurrence relations are
an = an-1, an = an-1 + an-2, an = 3an-1, and an = an-1 + an-2 + an-3, respectively.
The key fact about linear nonhomogeneous recurrence relations with constant coefficients
is that every solution is the sum of a particular solution and a solution of the associated linear
homogeneous recurrence relation.
Theorem 4: If anp is a particular solution of the nonhomogeneous linear recurrence relation with
constant coefficients 𝑎𝑛 =𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 + 𝑓(𝑛),
then all solution is of the form 𝑎𝑛 = 𝑎𝑛ℎ + 𝑎𝑛𝑝 ,where 𝑎𝑛ℎ is a solution of the associated
homogeneous recurrence relation 𝑎𝑛 =𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 .
Example 1: Find all solutions of the recurrence relation 𝑎𝑛 =3𝑎𝑛−1 + 2𝑛. What is the solution
with a1 = 3?
Solution: To solve this linear nonhomogeneous recurrence relation with constant coefficients,
we need to solve its associated linear homogeneous equation and to find a particular solution for
the given nonhomogeneous equation. The associated linear homogeneous equation is 𝑎𝑛 =3𝑎𝑛−1 .
Its solutions are 𝑎𝑛ℎ = 𝛼3𝑛 where α is a constant.
We now find a particular solution. Because f(n) = 2n is a polynomial in n of degree
one, a reasonable trial solution is a linear function in n , say An + B, where A and B are
constants. To determine whether there are any solutions of this form, suppose that 𝑎𝑛𝑝 = An + B is
such a solution. By substitution on the recurrence relation 𝑎𝑛 =3𝑎𝑛−1 + 2𝑛, implies
An + B =3(A(n-1) + B) + 2n.
Simplifying and combining like terms gives
(2 + 2A)n+ (2B – 3A) = 0. It follows
2 + 2A = 0 and
2B – 3A = 0.
This shows that An + B is a solution if and only if A = −1 and B = −3/2.
Which implies, 𝑎𝑛𝑝 = −n − 3/2 is a particular solution.
Then all solutions are of the form 𝑎𝑛 = 𝑎𝑛ℎ + 𝑎𝑛𝑝 = 𝛼3𝑛 + −𝑛 − 3/2 , where α is a constant.
To find the solution with a1 = 3, let n = 1 on general solution. We find that 3 = −1 − 3/2 + 3α,
which implies that α = 11/6. Therefore the required solution is
38
Discrete Mathematics & Combinatorics
11
𝑎𝑛 = 3𝑛 + −𝑛 − 3/2.
6
Example 2: Find all solutions of the recurrence relation an = 5an-1 − 6an-2 + 7n.
Solution: This is a linear nonhomogeneous recurrence relation. The solutions of its associated
homogeneous recurrence relation an = 5an-1 − 6an-2 are 𝑎𝑛ℎ = α1·3n + α2·2n, where α1 and α2 are
constants.
Here f(n) = 7n, a reasonable trial solution is anp = C· 7n, where C is a constant.
Substituting the terms of this sequence into the recurrence relation implies that
C·7n = 5C · 7n-1 − 6C·7n-2 + 7n.
Dividing both sides of this equation by 7n-2 becomes 49C = 35C − 6C + 49,
⇒20C = 49, ⇒C = 49/20.
Hence, anp = (49/20)7n is a particular solution.
Therefore, all solutions are
an = α1· 3n + α2·2n + (49/20)7n
Theorem 5: Suppose that {an} satisfies the linear nonhomogeneous recurrence relation
𝑎𝑛 =𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + ⋯ + 𝑐𝑘 𝑎𝑛−𝑘 + 𝑓(𝑛), where c1, c2, . . . , ck are real numbers, and
f(n) = (btnt + bt-1nt-1 +· · ·+b1n+ b0)sn, where b0, b1, . . . , bt and s are real numbers. When s is not
a root of the characteristic equation of the associated linear homogeneous recurrence relation,
there is a particular solution of the form
anp = (ptnt + pt-1nt-1 +· · ·+p1n+ p0)sn
When s is a root of this characteristic equation and its multiplicity is m, there is a particular
solution of the form
anp = nm(ptnt + pt-1nt-1 +· · ·+p1n+ p0)sn
Note that in the case when s is a root of multiplicity m of the characteristic equation of
the associated linear homogeneous recurrence relation, the factor nm ensures that the proposed
particular solution will not already be a solution of the associated linear homogeneous recurrence
relation.
Example 1: What form does a particular solution of the linear nonhomogeneous recurrence
relation an = 6an-1 − 9an-2 +f(n) have when
a) f(n) = 3n
b) f(n) = n3n,
c) f(n) = n22n
39
Discrete Mathematics & Combinatorics
is r2 – 3r + 2 = 0. Its roots are r = 1 and r = 2. Hence the general solution to the homogeneous
equation is 𝑎𝑛ℎ = 𝛼1 1𝑛 + 𝛼2 2𝑛 = 𝛼1 + 𝛼2 2𝑛 . In order to find a particular solution to the non-
homogeneous solution, let anp = (An+B)n2n be a particular solution of the given
nonhomogeneous recurrence relation. Then by substitution we have,
Example: Solve the recurrence equation an - 5an-1 + 6an-2 = 2n + n with initial condition a1 = 0
and a2 = 10.
Solution: The general to the problem is given by the homogeneous part of the given recurrence
equation.
The homogeneous part of the equation is
anh
Let particular solution be
anp =
Substituting this particular solution in the given recurrence relation , we have
41
Discrete Mathematics & Combinatorics
Replacing the values of A and B, we get the closed form formula for the given
recurrence equation
42
Discrete Mathematics & Combinatorics
43
Discrete Mathematics & Combinatorics
solve recurrence relations by translating a recurrence relation for the terms of a sequence into an
equation involving a generating function. This equation can then be solved to find a closed form
for the generating function. From this closed form, the coefficients of the power series for the
generating function can be found, solving the original recurrence relation.
Definition: The generating function for the sequence a0, a1. . . ak, . . . of real numbers is the
infinite series
Note: The generating function for {ak} given in the above definition is sometimes called the
ordinary
generating function of {ak} to distinguish it from other types of generating functions for this
sequence.
Example 1: The generating functions for the sequences {ak} with
a) ak= 3,
b) ak = k + 1
c) ak = 2k
are
G(x) =
.
Example 3: Let m be a positive integer. Let ak = C(m, k), for k = 0, 1, 2, . . . , m. What is the
generating function for the sequence a0, a1, . . . , am?
Solution: The generating function for this sequence is
Example 4:
Example 5:
45
Discrete Mathematics & Combinatorics
Example 8: The sequence 1, 3, 7, 15, 31, 63, . . . satisfies the recurrence relation
an = 3an-1 − 2an-2. Find the generating function for the sequence.
Solution: Call the generating function for the sequence A. We have
Definition:
46
Discrete Mathematics & Combinatorics
EXAMPLE 2: When the top parameter is a negative integer, the extended binomial coefficient
can be expressed in terms of an ordinary binomial coefficient. To see that this is the case, note
that
Let x be a real number with |x| < 1 and let u be a real number. Then
Example 1: Find the generating functions for (1 + x)-n and (1 − x)-n, where n is a positive integer,
using the extended binomial theorem.
Solution: By the extended binomial theorem, it follows that
47
Discrete Mathematics & Combinatorics
48
Discrete Mathematics & Combinatorics
Example 2: Since Heather’s neighbors just moved in, she thought it would be nice to put
together a fruit basket for them in the basket she recently made at summer camp. When
Heather’s mother returned from the grocery store, she had a bag containing apples, bananas, and
oranges. How many different possibilities are there for a fruit basket consisting of 36 pieces of
fruit if
a) there is an ample supply of apples and bananas, but there are only 4 oranges?
b) there are 16 of each kind of fruit?
c) there is an ample supply of bananas and oranges, and there are 4 distinguishable apples
(one Cortland, one Delicious, one Empire, and one Macintosh)?
In each case, fruit baskets are distinguished solely by how many of each type
of fruit they contain.
Solution:
49
Discrete Mathematics & Combinatorics
50
Discrete Mathematics & Combinatorics
Example 2: Use generating functions to find an explicit formula for an for the recurrence
relation
Solution:
51
Discrete Mathematics & Combinatorics
52
Discrete Mathematics & Combinatorics
Exercise 2.2
1. For each recurrence relation and initial conditions, find: (i) general solution; (ii) unique
solution with the given initial conditions:
53
Discrete Mathematics & Combinatorics
3. Find the unique solution to each recurrence relation with the given initial conditions:
a)
b)
4.
5.
6. What is the general form of the particular solution of the linear non homogeneous recurrence
relation
54
Discrete Mathematics & Combinatorics
f) 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, . . .
g) 0, 0, 0, 1, 2, 3, 4, . . .
10. Find a closed form for the generating function for the sequence {an}, where
a) an = 5 for all n = 0, 1, 2, . . . .
b) an= 3n for all n = 0, 1, 2, . . . .
c) an = 2 for n = 3, 4, 5, . . . and a0 = a1 = a2 = 0.
d) an = 2n + 3 for all n = 0, 1, 2, . . . .
11. Find a generating function for the sequence with recurrence relation an = 3an -1 – an-2 with
initial terms a0 = 1 and a1 = 5.
12. Find the generating function for the sequence with closed formula an = 2(5n) + 7(−3)n.
13. Find a closed formula for the nth term of the sequence with generating function
G(x) =
14. For each of these generating functions, provide a closed formula for the sequence it
determines.
15. Use generating functions to solve the recurrence relation ak = 5ak-1 − 6ak-2 with initial
conditions a0 = 6 and a1 = 30.
16. Use generating functions to solve the recurrence relation ak = ak-1 + 2ak-2 + 2k with initial
conditions a0 = 4 and a1 = 12.
Review Exercise
55
Discrete Mathematics & Combinatorics
56
Discrete Mathematics & Combinatorics
Chapter Three
Elements of Graph Theory
Chapter Objectives
On completion of this chapter, students will be able to
Understand a graph.
Understand simple graph and multi graph.
Know different types of simple graphs.
Understand isomorphism of two graphs.
Understand walk and path on a graph.
Understand connectivity of graphs.
Understand Eulerian graphs and Hamiltonian graphs.
Understand planar graph.
Understand tree.
Understand directed graph.
Introduction
Graphs are discrete structures consisting of vertices and edges that connect these vertices. There
are different kinds of graphs, depending on whether edges have directions, whether multiple edges
can connect the same pair of vertices, and whether loops are allowed. Problems in almost every
conceivable discipline can be solved using graph models.
Objectives: On completion of subtopic, students will be able to.
Define a graph.
Identify simple graph and multi graph.
Identify different types of simple graphs.
Find degree of a vertex in an undirected graph.
State hand shaking theorem and verify it for any finite undirected graph.
Definition: A graph G = (V, E) consists of V, a nonempty set of vertices (or nodes) and E, a set
of edges. Each edge has either one or two vertices associated with it, called its endpoints. An
edge is said to connect its endpoints.
57
Discrete Mathematics & Combinatorics
E= {(a, b), (a, c),(a, d), (b, c), (b, d), (c, d)}
Then draw the graph G.
Solution: G is the graph below
b
a
c
d
Note: The set of vertices V of a graph G may be infinite. A graph with an infinite vertex set or an
infinite number of edges is called an infinite graph, and in comparison, a graph with a finite
vertex set and a finite edge set is called a finite graph.
Undirected graph
An undirected graph G consists of set V of vertices and a set E of edges such that each edge e ∈
E is associated with an unordered pair of vertices.
In other words, if each edge of the graph G has no direction then the graph is called undirected
graph.
We can refer to an edge joining the vertex pair i and j as either (i, j) or (j, i).
Example: The graph G below is an undirected graph.
58
Discrete Mathematics & Combinatorics
Definition: The degree of a vertex in an undirected graph is the number of edges incident with it,
except that a loop at a vertex contributes twice to the degree of that vertex. The degree of the
vertex v is denoted by deg(v).
Example 1: what are the degrees and what are the neighborhoods of the vertices in the graph G
displayed in Figure below?
N(c) = {b, d, e, f }, N(d) = {c}, N(e) = {b, c, f }, N(f ) = {a, b, c, e}, and N(g) = ∅.
Example 2: what are the degrees and what are the neighborhoods of the vertices in the graph G
displayed in figure below?
H
Solution: deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, and deg(d ) = 5. The neighborhoods of
these vertices are N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b}, N(d) = {a, b, e}, and N(e) =
{a, b, d}.
Isolated and pendent vertices
Isolated vertex
A vertex having no incident edge is called an isolated vertex. In other words, isolated vertices are
those with zero degree.
Pendent or end vertex
A vertex of degree one, is called a pendent vertex or an end vertex. In the above Figure, v5 is a
pendent vertex.
In degree and out degree
In a graph G, the out degree of a vertex vi of G, denoted by out degG (vi) or degG+ (vi), is the
number of edges beginning at vi and the in degree of vi, denoted by in degG (vi) or degG− (vi), is
the number of edges ending at vi.
The sum of the in degree and out degree of a vertex is called the total degree of the vertex.
Theorem 1: Handshaking theorem
If G = (v, E) be an undirected graph with e edges .then the sum of degrees of the vertices of G is
equal to twice the number of edges. i.e
60
Discrete Mathematics & Combinatorics
Solution: deg(a) = 2 , deg(b) = 2, deg(c) =4, deg(d) =2 deg(e) =2 and deg(f) =2.
e=7
deg(a) +deg(b) + deg(c) + deg(d)+deg(e) +deg(f) = 2*e
2+2+4+2+2+2 = 14 = 2*7.
Example 2: How many vertices and edges must a graph have if its degree sequence is (4, 4, 3, 3,
3, 2, 1)?
Solution: The number of vertices is easy to find, it is the number of degrees in the sequence: that
is 7. To find the number of edges, we compute the degree sum:
4 + 4 + 3 + 3 + 3 + 2 + 1 = 20,
so the number of edges is half this. Which is 10.
Example 3: Determine the number of edges in a graph with 6 vertices, 2 of degree 4 and 4 of
degree 2. Draw two such graphs.
Solution: Suppose the graph with 6 vertices has e number of edges. Therefore by Handshaking
theorm, we have
Hence the number of edges in a graph with 6 vertices with given condition is 8.
The graph is as follows
61
Discrete Mathematics & Combinatorics
Corollary 1: In a non-directed graph, the total number of odd degree vertices is even.
Example 4: How many edges are there in a graph with 10 vertices each of degree six?
Solution: Because the sum of the degrees of the vertices is 6 ・ 10 = 60, it follows that 2e = 60
K1 K2 K3 K4 K5
𝑛(𝑛−1)
Note: A complete graph with n vertices has C(n , 2) = edges.
2
ii) Cycles
Definition: A cycle graph Cn, n ≥ 3, consists of n vertices v1, v2, . . . , vn and edges (v1, v2),(v2,
v3) , . . . , (vn-1, vn}, and {vn, v1}.
Example 2: The cycles C3, C4 and C5 are given below
C3 C4 C5
62
Discrete Mathematics & Combinatorics
C6
G H
Solution: Graph G is bipartite because its vertex set is the union of two disjoint sets, {a, b, d} and
{c, e, f, g}, and each edge connects a vertex in one of these subsets to a vertex in the other subset.
Graph H is not bipartite because its vertex set cannot be partitioned into two subsets so that edges
do not connect two vertices from the same subset.
63
Discrete Mathematics & Combinatorics
Definition: A complete bipartite graph Km ,n is a graph that has its vertex set partitioned into two
subsets of m and n vertices, respectively with an edge between two vertices if and only if one
vertex is in the first subset and the other vertex is in the second subset.
Example 6: Draw the complete bipartite graphs K2,3 and K3,3.
Solution:
K2,3 K3,3.
K5 G
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
1. Define a graph (undirected graph).
2. Define simple graph and multi graph.
3. Define simple graphs (regular graph, complete graph, bipartite graph).
4. Find degree of a vertex in an undirected graph.
5. State handshaking theorem and verify it for any finite undirected
graph.
64
Discrete Mathematics & Combinatorics
Is your response positive for the above questions? If your answer is “I Can”, go to the next
section. If your answer is “I Can’t”, go back and read once again.
Exercise 3.1
1. Find the number of vertices, the number of edges, and the degree of each vertex in the given
undirected graph. Identify all isolated and pendant vertices.
G H
K
2. Find the sum of the degrees of the vertices of each graph in question no.1 and verify that it
equals twice the number of edges in the graph.
3. Draw the following graphs.
a) K7 b) K1,5 c) K4,4 d) C7
4. Determine whether the following graphs are bipartite or not.
G1 G2
G3 G4
5. Which of the graphs below are bipartite? Justify your answers.
65
Discrete Mathematics & Combinatorics
G1 G2 G3 G4
6. For which values of n are these graphs bipartite.
a) Kn b) Cn
7. How many vertices and how many edges do these graphs have?
a) Kn b) Cn
8. How many edges does a graph have if its degree sequence is 4, 3, 3, 2, 2? Draw such a graph.
9. How many edges does a graph have if its degree sequence
is 5, 2, 2, 2, 2, 1? Draw such a graph.
10. For which values of n are these graphs regular?
a) Kn b) Cn
11. For which values of m and n is Km,n regular?
12. If 10 people each shake hands with each other, howmany handshakes took place? What does
this question have to do with graph theory?
Isomorphism of Graph
Definition: The simple graphs G1 = (V1 ,E1) and G2 = (V2 ,E2) are isomorphic if there exists a one
-to-one and onto function f from V1 to V2 with the property that a and b are adjacent in G1 if
and only if f (a) and f (b) are adjacent in G2, for all a and b in V1. Denoted by G1≅ G2.
Two simple graphs that are not isomorphic are called non isomorphic. In other words, when two
simple graphs are isomorphic, there is a one-to-one correspondence
66
Discrete Mathematics & Combinatorics
between vertices of the two graphs that preserves the adjacency relationship.
Example 1: Show that the graphs G = (V ,E) and H = (W, F) are isomorphic.
G H
Solution: Take the function f with f (u1) = v1, f (u2) = v4,
f (u3) = v3, and f (u4) = v2
is a one to-one and onto function between V and W. To see that this correspondence preserves
adjacency.
In graph G u1 and u2, u1 and u3, u2 and u4 and u3 and u4, and each of the pairs f (u1) = v2 and
f (u2) = v4, f (u1) = v1 and f (u3) = v3, f (u2) = v4 and f (u4) = v2 and f (u3) = v3 and f (u4) = v2
consists of two adjacent vertices in H.
Therefore, the graphs G and H are isomorphic.
Example 2: Decide whether the graphs G1 = {V1, E1} and G2 = {V1, E2} are isomorphic.
V1 = {a, b, c, d}, E1 = {{a, b}, {a, c}, {a, d}, {c, d}}
V2 = {a, b, c, d}, E2 = {{a, b}, {a, c}, {b, c}, {c, d}}
Solution: We can try to build an isomorphism. How about we say f (a) = b, f (b) = c, f (c) = d
and f (d) = a. This is definitely a bijection, but to make sure that the function is an isomorphism.
Alternatively, notice that in G1, the vertex a is adjacent to every other vertex. In G2, there is also
a vertex with this property: c. So build the bijection g : V1 → V2 by defining g(a) = c to start
with. Next, where should we send b? In G1, the vertex b is only adjacent to vertex a. There is
exactly one vertex like this in G2, namely d. So let g(b) = d. As for the last two, in this example,
we have a free choice: let g(c) = b and g(d) = a.
We should check that this really is an isomorphism. It is definitely a bijection. We must make
sure that the edges are respected.
The four edges in G1 are {a, b}, {a, c}, {a, d}, {c, d}.
67
Discrete Mathematics & Combinatorics
G H
Solution: Both G and H have five vertices and six edges. However,H has a vertex of degree one,
namely, e, whereas G has no vertices of degree one. It follows that G and H are not isomorphic.
Matrix Representations of Graphs
i) Adjacency Matrix
ii) Incidence Matrix
68
Discrete Mathematics & Combinatorics
Definition: Suppose that G = (V ,E) is a simple graph where |V| = n. Suppose that the vertices of
G are listed arbitrarily as v1, v2, . . . , vn. The adjacency matrix A (or AG) of G, with respect
to this listing of the vertices, is the n x n zero–one matrix with 1 as its (i, j )th entry when vi
and vj are adjacent, and 0 as its (i, j )th entry when they are not adjacent. In other words, if its
adjacency matrix is A = [aij ], then
Example 5: Draw a graph with the adjacency matrix with respect to the ordering of vertices a, b,
c, d.
69
Discrete Mathematics & Combinatorics
Definition: Let G = (V ,E) be an undirected graph. Suppose that v1, v2, . . . , vn are the vertices
and e1, e2, . . . , em are the edges of G. Then the incidence matrix with respect to this ordering of
V and E is the n × m
matrix
G
Solution: The incidence matrix of G is
Note: If the adjacency matrix of G is the same as the adjacency matrix of H, then the two graphs
are isomorphic.
G H
Solution: Both G and H have six vertices and seven edges. Both have four vertices of degree two
and two vertices of degree three. It is also easy to see that the subgraphs of G and H consisting of
all vertices of degree two and the edges connecting them are isomorphic. Because G and H agree
with respect to these invariants,
The adjacency matrix of G is
70
Discrete Mathematics & Combinatorics
Here both G2 and G3 are subgraphs of G1. But only G2 is an induced subgraph. Every edge in G1
that connects vertices in G2 is also an edge in G2. In G3, the edge {a, b} is in E1 but not E3, even
though vertices a and b are in V3.
The graph G4 is not a subgraph of G1, even though it looks like all we did is remove vertex e.
The reason is that in E4 we have the edge {c, f } but this is not an element of E1, so we don’t
have the required E4 ⊆ E1.
71
Discrete Mathematics & Combinatorics
Example 2:
72
Discrete Mathematics & Combinatorics
Definition: Let n be a nonnegative integer and G an undirected graph. A path of length n from u
to v in G is a sequence of n edges e1,e2 . . . , en of G for which there exists a sequence x0 = u, x1, . .
. , xn-1, xn = v of vertices such that ei has, for i = 1, . . . , n, the endpoints xi-1 and xi . When the graph
is simple, we denote this path by its vertex sequence x0, x1, . . . , xn (because listing these vertices
uniquely determines the path).
The path is a circuit if it begins and ends at the same vertex, that is, if u = v, and has length greater
than zero. The path or circuit is said to pass through the vertices x1, x2. . . xn-1 or traverse the edges
e1, e2, . . . , en.
A path or circuit is simple if it does not contain the same edge more than once.
Example 1: In the simple graph H shown below a, d, c, f , e is a simple path of length 4, because
{a, d},{d, c}, {c, f }, and {f, e} are all edges. However, d, e, c, a is not a path, because {e, c} is
not an edge. Note that b, c, f , e, b is a circuit of length 4 because {b, c}, {c, f }, {f, e}, and {e, b}
are edges, and this path begins and ends at b. The path a, b, e, d, a, b, which is of length 5, is not
simple because it contains the edge {a, b} twice.
H
A path or circuit is called simple if it does not contain the same edge more than once.
73
Discrete Mathematics & Combinatorics
Example 1: The graph G1 given below is connected, because for every pair of distinct vertices
there is a path between them. However, the graph G2 is not connected. For instance, there is no
path in G2 between vertices a and d.
G1 G2
Theorem 2: There is a simple path between every pair of distinct vertices of a connected
undirected graph.
A connected component of a graph G is a connected subgraph of G that is not a proper subgraph
of another connected subgraph of G. That is, a connected component of a graph G is a maximal
connected subgraph of G.A graph G that is not connected has two or more connected components
that are disjoint and have G as their union.
Example 2: What are the connected components of the graph H?
Solution: The graph H is the union of three disjoint connected subgraphs H1, H2, and H3.
.These three subgraphs are the connected components of H given below.
H1 H2 H3
How Connected is a Graph?
Suppose that a graph represents a computer network. Knowing that this graph is connected tells
us that any two computers on the network can communicate. However, we would also like to
understand how reliable this network is. For instance, will it still be possible for all computers to
communicate after a router or a communications link fails? To answer this and similar questions,
we now develop some new concepts.
74
Discrete Mathematics & Combinatorics
Sometimes the removal from a graph of a vertex and all incident edges produces a subgraph with
more connected components. Such vertices are called cut vertices (or articulation points).
The removal of a cut vertex from a connected graph produces a subgraph that is not connected.
Analogously, an edge whose removal produces a graph with more connected components than
in the original graph is called a cut edge or bridge. Note that in a graph representing a computer
network, a cut vertex and a cut edge represent an essential router and an essential link that cannot
fail for all computers to be able to communicate.
Example 1: Find the cut vertices and cut edges in the graph G.
Solution: The cut vertices of G are b, c, and e. The removal of one of these vertices (and its
adjacent edges) disconnects the graph. The cut edges are {a, b} and {c, e}. Removing either one
of these edges disconnects G1.
A subset U of the vertex set V of G = (V , E) is a vertex cut, or separating set, if G – U is
disconnected. For instance, in the following graph G, the set {b, c, e} is a vertex cut with three
vertices.
G
Paths and Isomorphism
There are several ways that paths and circuits can help determine whether two graphs are
isomorphic.
For example, the existence of a simple circuit of a particular length is a useful invariant that can
be used to show that two graphs are not isomorphic. In addition, paths can be used to construct
mappings that may be isomorphism.
75
Discrete Mathematics & Combinatorics
As we mentioned, a useful isomorphic invariant for simple graphs is the existence of a simple
circuit of length k, where k is a positive integer greater than 2.
Example 2: Determine whether the graphs G and H shown below are isomorphic.
G H
Solution: Both G and H have six vertices and eight edges. Each has four vertices of degree three,
and two vertices of degree two. So, the three invariants number of vertices, number of edges, and
degrees of vertices all agree for the two graphs. However, H has a simple circuit of length three,
namely, v1, v2, v6, v1, whereas G has no simple circuit of length three, as can be determined by
inspection (all simple circuits in G have length at least four). Because the existence of a simple
circuit of length three is an isomorphic invariant, G and H are not isomorphic.
Example 3: Determine whether the graphs G1 and G2 are isomorphic.
Solution: Both G and H have five vertices and six edges, both have two vertices of degree three
and three vertices of degree two, and both have a simple circuit of length three, a simple circuit
of length four, and a simple circuit of length five. Because all these isomorphic invariants agree,
G and H may be isomorphic.
To find a possible isomorphism, we can follow paths that go through all vertices so that the
corresponding vertices in the two graphs have the same degree. For example, the paths u1, u4, u3,
u2, u5 in G and v3, v2, v1, v5, v4 in H both go through every vertex in the graph; start at a vertex of
degree three; go through vertices of degrees two, three, and two, respectively; and end at a vertex
of degree two. By following these paths through the graphs, we define the mapping f with f (u1) =
76
Discrete Mathematics & Combinatorics
v3, f (u4) = v2, f (u3) = v1, f (u2) = v5, and f (u5) = v4. This show that f is an isomorphism, so G and
H are isomorphic.
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
a)
G H
b)
G1 G2
77
Discrete Mathematics & Combinatorics
c)
G H
d)
G1 G2
3. Represent the given graphs using
a) Adjacency matrix.
b) Incidence matrix
G1 G2
G3
c) Draw an undirected graph represented by the given adjacency matrix.
78
Discrete Mathematics & Combinatorics
A1 = A2 =
A3 =
4. Are the simple graphs with the following adjacency matrices isomorphic?
G H
79
Discrete Mathematics & Combinatorics
G1 G2
11. Find all the cut edges in the graphs G1 and G2 on Q no. 10 above.
12. Find κ(Km,n) and λ(Km,n), where m and n are positive integers.
13. Draw a graph G with κ(G) = 1, λ(G) = 2, and minv∈V deg(v) = 3.
80
Discrete Mathematics & Combinatorics
Example: Which of the undirected graphs given below are Eulerian graph?
G1 G2 G3
Solution: The graph G1 has an Euler circuit, for example, a, e, c, d, e, b, a. Neither of the graphs
G2 or G3 has an Euler circuit.
However, G3 has an Euler path a, c, d, e, b, d, a, b. G2 does not have an Euler path.
Therefore, G1 is Eulerian graph.
81
Discrete Mathematics & Combinatorics
Example 2: Show that neither graph displayed below has a Hamilton circuit.
Solution: There is no Hamilton circuit in G because G has a vertex of degree one, namely, e.
Now consider H. Because the degrees of the vertices a, b, d, and e are all two, every edge
incident with these vertices must be part of any Hamilton circuit. It is now easy to see that no
Hamilton circuit can exist in H, for any Hamilton circuit would have to contain four edges
incident with c, which is impossible.
Example 3: Show that K5 has a Hamilton circuit whenever n ≥ 3.
Solution: We can form a Hamilton circuit in K5 beginning at any vertex. Such a circuit can be
built by visiting vertices in any order we choose, as long as the path begins and ends at the same
vertex and visits each other vertex exactly once. This is possible because there are edges in K5
between any two vertices.
Definition: A graph is called planar if it can be drawn in the plane without any edges crossing ,
where a crossing of edges is the intersection of the lines or arcs representing them at a point other
than their common endpoint. Such a drawing is called a planar representation of the graph.
A graph may be planar even if it is usually drawn with crossings, because it may be possible to
draw it in a different way without crossings.
Example 1: Is K4 planar?
Solution: K4 is planar because it can be drawn without crossings as shown below.
82
Discrete Mathematics & Combinatorics
83
Discrete Mathematics & Combinatorics
Example 1: Suppose that a connected planar simple graph has 20 vertices, each of degree 3. Into
how many regions does a representation of this planar graph split the plane?
Solution: This graph has 20 vertices, each of degree 3, so v = 20. Because the sum of the degrees
Solution: The graph K5 has five vertices and 10 edges. However, the inequality e ≤ 3v − 6 is
not satisfied for this graph because e = 10 and 3v − 6 = 3(5) – 6 = 9. Implies 10 > 9.Therefore,
K5 is not planar.
Theorem 4: Kuratowski’s Theorem
A graph is nonplanar if and only if it contains a subgraph which is a subdivision of K3,3 or K5.
Trees are particularly useful in computer science, where they are employed in a wide range of
algorithms. For instance, trees are used to construct efficient algorithms for locating items in a list.
They can be used in algorithms, such as Huffman coding, that construct efficient codes saving
costs in data transmission and storage. Trees can be used to study games such as checkers and
chess and can help determine winning strategies for playing these games. Trees can be used to
model procedures carried out using a sequence of decisions. Constructing these models can help
determine the computational complexity of algorithms based on a sequence of decisions, such as
sorting algorithms.
84
Discrete Mathematics & Combinatorics
We can assign weights to the edges of a tree to model many problems. For example, using weighted
trees we can develop algorithms to construct networks containing the least expensive set of
telephone lines linking different network nodes.
Definition: A tree is a simple connected undirected graph with no simple circuits.
Example 1: Which of the graphs shown below are trees?
Solution: G1 and G2 are trees, because both are connected graphs with no simple circuits. G3 is
not a tree because e, b, a, d, e is a simple circuit in this graph. Finally, G4 is not a tree because
it is not connected.
Trees are often defined as undirected graphs with the property that there is a unique simple path
between every pair of vertices.
THEOREM 5: An undirected graph is a tree if and only if there is a unique simple path between
any two of its vertices.
Theorem 6: A tree T with n vertices has exactly (n – 1) edges.
Example: A graph G1 on example1 above is tree with n = 6 vertices and 6 – 1 = 5 edges.
Definition: A forest is a graph that contains no cycles.
Example: The graph G given below is forest with 9 vertices and 6 edges.
b e g h
a c
f i
d
G
85
Discrete Mathematics & Combinatorics
Definition: The diameter of a connected r graph G is defined as the maximum eccentricity among
all vertices of the graph G. It is denoted by d.
Hence, d = diameter of G = max {e (v): v ∈V}
Definition: The radius of a connected graph G is defined as the maximum eccentricity among all
vertices of the graph. It is denoted by r.
Thus r = radius of G = min {e(v): v ∈V}
Note: The radius of connected graph may not be half of its diameter.
Example: Consider the tree T below.
86
Discrete Mathematics & Combinatorics
G
Solution: e (v1) = 4, e (v2) = 3, e (v3) = 2,
e (v4) = 3, e (v5) = 4, radius of G = i = 2.
Hence center of G = {v3}.
Note:
i. The distance between two adjacent vertices of a connected graph G is 1.
ii. The maximum distance from each vertex of G occurs at a pendant vertices of G.
iii. If C (G) = V (G) then G is called self-centred graph.
iv. If P is a path of even length the P has only one vertex at the centre.
v. If P is a path of odd length this centre of P contains two adjacent vertices.
Example 2: In the graph G below.
G
Solution: Centre of G = {v3, v4}
87
Discrete Mathematics & Combinatorics
Rooted Trees
Definition: A rooted tree is a tree in which one vertex has been designated as the root and every
edge is directed away from the root.
The terminology for trees has botanical and genealogical origins. Suppose that T is a rooted tree.
If v is a vertex in T other than the root, the parent of v is the unique vertex u such that there is a
directed edge from u to v (the reader should show that such a vertex is unique). When u is the
parent of v, v is called a child of u. Vertices with the same parent are called siblings. The ancestors
of a vertex other than the root are the vertices in the path from the root to this vertex, excluding
the vertex itself and including the root (that is, its parent, its parent’s parent, and so on, until the
root is reached). The descendants of a vertex v are those vertices that have v as an ancestor. A
vertex of a rooted tree is called a leaf if it has no children. Vertices that have children are called
internal vertices. The root is an internal vertex unless it is the only vertex in the graph, in which
case it is a leaf.
If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree consisting of a and
its descendants and all edges incident to these descendants.
Example 1: In the rooted tree T (with root a) shown below, find the parent of c, the children of
g, the siblings of h, all ancestors of e, all descendants of b, all internal vertices, and all leaves.
What is the subtree rooted at g?
Solution: The parent of c is b. The children of g are h, i, and j . The siblings of h are i and j .
The ancestors of e are c, b, and a. The descendants of b are c, d, and e. The internal vertices
are a, b, c, g, h, and j . The leaves are d, e, f , i, k, l, and m. The subtree rooted at g is shown
below
88
Discrete Mathematics & Combinatorics
Note: Rooted trees with the property that all of their internal vertices have the same number of
children are used in many different applications. like searching, sorting, and coding.
Definition: A rooted tree is called an m-ary tree if every internal vertex has no more than m
children.
The tree is called a full m-ary tree if every internal vertex has exactly m children. An m-ary
tree with m = 2 is called a binary tree.
Example 1: Are the rooted trees given below full m-ary trees for some positive integer m?
Solution: T1 is a full binary tree because each of its internal vertices has two children. T2 is a
full 3-ary tree because each of its internal vertices has three children. In T3 each internal vertex
has five children, so T5 is a full 5-ary tree. T4 is not a full m-ary tree for any m because some of
its internal vertices have two children and others have three children.
Ordered rooted trees
Definition: An ordered rooted tree is a rooted tree where the children of each internal vertex are
ordered. Ordered rooted trees are drawn so that the children of each internal vertex are shown in
order from left to right. Note that a representation of a rooted tree in the conventional way
determines an ordering for its edges. We will use such orderings of edges in drawings without
explicitly mentioning that we are considering a rooted tree to be ordered.
89
Discrete Mathematics & Combinatorics
In an ordered binary tree (usually called just a binary tree), if an internal vertex has two children,
the first child is called the left child and the second child is called the right child.
The tree rooted at the left child of a vertex is called the left subtree of this vertex, and the tree
rooted at the right child of a vertex is called the right subtree of the vertex. The reader should note
that for some applications every vertex of a binary tree, other than the root, is designated as a right
or a left child of its parent. This is done even when some vertices have only one child.
Example 1: What are the left and right children of d in the binary tree T shown below (where the
order is that implied by the drawing)? What are the left and right subtrees of c?
T1 T2
90
Discrete Mathematics & Combinatorics
G
Solution: The graph G is connected, but it is not a tree because it contains simple circuits.
Remove the edge {a, e}. This eliminates one simple circuit, and the resulting subgraph is still
connected and still contains every vertex of G. Next remove the edge {e, f } to eliminate a
second simple circuit. Finally, remove edge {c, g} to produce a simple graph with no simple
circuits. This subgraph is a spanning tree, because it is a tree that contains every vertex of G.
T1
T2 T3
91
Discrete Mathematics & Combinatorics
T4 T5
92
Discrete Mathematics & Combinatorics
Definition: The chromatic number of a graph is the least number of colors needed for a coloring
of this graph. The chromatic number of a graph G is denoted by χ(G). (Here χ is the Greek letter
chi.)
Example 1: What are the chromatic numbers of the graphs G and H given below?
Solution: The chromatic number of G is at least three, because the vertices a, b, and c must be
assigned different colors. To see if G can be colored with three colors, assign red to a, blue to b,
and green to c. Then, d can (and must) be colored red because it is adjacent to b and c.
Furthermore, e can (and must) be colored green because it is adjacent only to vertices colored red
and blue, and f can (and must) be colored blue because it is adjacent only to vertices colored red
and green. Finally, g can (and must) be colored red because it is adjacent only to vertices colored
blue and green. This produces a coloring of G using exactly three colors. i.e χ(G) = 3.
The graph H is made up of the graph G with an edge connecting a and g. Any attempt to color H
using three colors must follow the same reasoning as that used to color G, except at the last stage,
when all vertices other than g have been colored. Then, because g is adjacent (in H) to vertices
colored red, blue, and green, a fourth color, say brown, needs to be used. Hence, H has a chromatic
number equal to 4. i.e χ(G) = 4.
The coloring of G and H using 3 and 4 colors respectively are given below
93
Discrete Mathematics & Combinatorics
5 coloring of K5 2 coloring of K3 , 4
94
Discrete Mathematics & Combinatorics
C6 C5
2 coloring and 3 coloring of C6 and C5
THEOREM: The four color theorem
The chromatic number of a planar graph is not greater than four.
Note:
- χ (G) ≤ | V |, where | V | is the number of vertices of G.
- If some subgraph of G requires k colors then χ (G) ≥k.
- If deg(v) = d, then at most d colors are required to color the vertices adjacent to v.
A directed graph or digraph D consists of a set V of vertices and a set E of edges such that e ∈E
is associated with an ordered pair of vertices.
In other words, if each edge of the graph D has a direction then the graph is called directed graph.
In the diagram of directed graph, each edge e = (u, v) is represented by an arrow or directed curve
from initial point u of e to the terminal point v.
The following graph is an example of a directed graph.
Directed graph D
95
Discrete Mathematics & Combinatorics
Definition: A directed graph D that contain a directed self-loop an directed parallel edges is said
Note: The initial vertex and terminal vertex of loop are the same.
Definition: In a directed graph D, if there is no more than one directed edge in a particular direction
between a pair of vertices, then it is called simple directed graph.
Note: A directed graph which is not simple is called directed multi graph.
D1 D2
Definition: Let D be a directed graph the out degree of a vertex v of D is the number of edge
Definition: Let D be a directed graph the in degree of vertex v of D is the number of edge
deg-(v).
Note: a directed loop contributes one for out-degree and one for in degree.
G
96
Discrete Mathematics & Combinatorics
Theorem 7: Let G=(V,E) be a graph with directed edges then the sum of the in- degrees and the
sum of out- degrees of all vertices in a graph are equal. Both of these sums are equal to number
of edges in the graph.
1+3+3+0=2+2+1+2
⇒ 7 = 7 = |E|
Definition: A vertex with zero in- degree is called a source where as a vertex without zero out-
Solution: D
A=
97
Discrete Mathematics & Combinatorics
Remark:- The adjacency matrices can also be used to represent directed multi graphs. Again
such matrices are not zero one matrices. When there are multiple edges in the same direction
connecting two vertices in the adjacency matrix for a directed multi graph aij equals the number
of edges that are associated to (vi,vj).
Definition: The incidence matrix B = {bij} of a di graph D with n vertices and m edges is the
0, otherwise
Definition: A directed graph is strongly connected if there is a path from a to b and from b to a
whenever a and b are vertices in the graph. In other word, a directed graph to be strongly connected
there must be a sequence of directed edges from any vertex in the graph to any other vertex.
98
Discrete Mathematics & Combinatorics
Definition: A directed graph is weakly connected if there is a path between any two vertices in the
underlying undirected graph. That is a directed graph is weakly connected if and only if there is
always a path between two vertices when the direction of the edges are disregarded.
Example:
Solution: G is strongly connected because there is a path between any two vertices in this
directed graph and G is also can be weakly connected. H is not strongly connected because there
is no directed path from a to b in this graph , hence H is weakly connected graph.
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
1. Define Eulerian graph and Hamiltonian graph.
2. Find Eulerian circuit in a graph if it exist.
3. Find Hamiltonian cycle in a graph if it exist.
4. Determine whether a graph is Eulerian or not.
5. Determine whether a graph is Hamiltonian or not.
6. Define planar graph.
7. Determine whether a graph is planar or nonplanar.
8. State Euler’s formula.
9. Verify Euler’s formula for a connected planar graph.
10. Define tree graph.
11. Determine whether a graph is a tree or not.
99
Discrete Mathematics & Combinatorics
Is your response positive for the above questions? If your answer is “I Can”, go to the next
section. If your answer is “I Can’t”, go back and read once again.
Exercise 3.3
1. Determine whether the given graph has an Euler circuit or not. Construct such a circuit
when one exists.
G1 G2
G3
2. For which values of n do these graphs have an Euler circuit?
a) Kn b) Cn
3. Determine whether the given graph has a Hamilton circuit.
G H
100
Discrete Mathematics & Combinatorics
G1 G2
G3
5. Determine whether the given graph is planar. if so, draw it so that no edges cross.
G H
H1 H2
6. Suppose that a connected planar graph has eight vertices, each of degree three. Into how
many regions is the plane divided by a planar representation of this graph?
7. Suppose that a connected planar graph has six vertices, each of degree four. Into how
many regions is the plane divided by a planar representation of this graph?
8. Suppose that a connected planar graph has 30 edges. If a planar representation of this
graph divides the plane into 20 regions, how many vertices does this graph have?
9. Which of these nonplanar graphs have the property that the removal of any vertex and all
edges incident with that vertex produces a planar graph?
a) K5 b) K6 c) K3,3 d)K3,4
10. Which of these graphs are trees?
101
Discrete Mathematics & Combinatorics
G
12. Which of the following graphs are trees?
(a) G = (V, E) with V = {a, b, c, d, e} and
E = {{a, b}, {a, e}, {b, c}, {c, d}, {d, e}}
(b) G = (V, E) with V = {a, b, c, d, e} and
E = {{a, b}, {b, c}, {c, d}, {d, e}}
(c) G = (V, E) with V = {a, b, c, d, e} and
E = {{a, b}, {a, c}, {a, d}, {a, e}}
(d) G = (V, E) with V = {a, b, c, d, e} and E = {{a, b}, {a, c}, {d, e}}
13. Answer these questions about the rooted tree illustrated.
102
Discrete Mathematics & Combinatorics
G1
G2
d) e)
103
Discrete Mathematics & Combinatorics
G1 G2
G3 G4
16. Determine whether each of these graphs is strongly connected and if not, whether it is weakly
connected.
G1 G2
G3 G4
Review Exercise
104
Discrete Mathematics & Combinatorics
105
Discrete Mathematics & Combinatorics
Chapter 4
Chapter Objectives
On completion of this chapter, students will be able to
Definition: A graph G = (V, E) is called weighted graph if each edge of graph G is assigned
positive number we called the weight of the edge. Such weights might represent for example costs,
lengths or capacities, depending on the problem at hand. Some authors call such a graph a network.
106
Discrete Mathematics & Combinatorics
G H
Definition: Let G= (V, E) be a connected weighted graph. A minimum spanning trees T of the
graph G is a tree whose total weight is smallest among all the spanning trees of the graph G. Total
weight of a spanning tree is the sum of the weights of each edges on the spanning tree.
a
4 1
2 b
d 5
3
c
G
107
Discrete Mathematics & Combinatorics
T8
Tw(T1) = 4+3+5 = 12 , Tw(T2) =4+1+5 =10, Tw(T3) =1+2+5 = 8, Tw(T4) =4+3+5 =12, Tw(T5) =
4+2+5 =11, Tw(T6) = 4+2+5 = 9, Tw(T7) = 1+2+3 = 6, Tw(T8) = 4+3+2 = 9
108
Discrete Mathematics & Combinatorics
There are two famous algorithms finding the minimum spanning tree:
i. Kruskal’s Algorithm
Kruskal’s Algorithm builds the spanning tree by adding edges one by one into a growing spanning
tree. This algorithm finds an edge which has least weight and add it to the growing Kruskal’s
Algorithm
G
Solution: We have n = 6
We order the edges by increasing weights (v2, v4) is edge with minimum weight. Select the
edge(v2, v4) we successively add edges to (v2, v4), without forming cycles until 6 – 1 = 5 edges
109
Discrete Mathematics & Combinatorics
Edges in the minimum spanning tree are (v2, v4), (v1, v5), (v4, v6), (v3, v5), (v1, v6). The resulting
minimal (optimal) spanning tree is
In Prim’s Algorithm we grow the spanning tree from starting position. Unlike an edge in Kruskal’s,
we add vertex to the growing spanning tree in Prim’s
Step2. Choose an edge e1 =(v1, v2) of G such that v2 ≠ v1 and e1 has smallest weight among the
Step3. If edges e1, e2 ,…, ei have been choosen involving end points v1, v2, …, vi+1. Choose an edge
ei+1= (vj, vk) with vjϵ ( v1, v2, …, vi+1) and vk∉ (v1, v2, …, vi+1) such that ei+1 has smallest weight
among the of G with precisely one end in (v1, v2, …, vi+1).
Step4. Stop after n-1 edges n-1 edges have been choosen
Example: Find the minimal spanning tree of the weighted graph in figure below by Prim’s
algorithm.
110
Discrete Mathematics & Combinatorics
Solution: Let denote the edge of G ; e1 = (v1, v2), e2 = (v2, v3) , e3 = (v3, v4), e4 = (v4, v1) , e5 = (v2,
v5) and e6 = (v4, v6).
We next consider the edges connecting a vertex {v3, v4} with the vertex of the set V – {v3, v4}.
We observe that e6 the edge with minimum weight.
Consider the edges connecting the vertices of the set {v3, v4, v6} with the vertices of V – {v3, v4,
v6}. The edge e2 has the minimum weight. The edge e2 is selected.
111
Discrete Mathematics & Combinatorics
of the connecting the vertices of {v2, v3, v4, v6}; with the vertex set V – {v2, v3, v4, v6}, e4 has
minimum weight, therefore e4 is selected.
e1, e5 are the edges remaining. e5 is the only edge connecting {v1, v2, v3, v4, v5, v6} and {v5} such
that the inclusion of e5 does not result in a cycle. Hence e5 is selected. Since number of edges
selected is 5 we stop.
The minimal spanning tree obtained is shown below
In many areas like transportation, cartoon motion planning, communication network topology
design etc, problems related to finding shortest path algorithms.
The shortest path problem is concerned with finding the least cost (that costs minimum) path
from an originating node in a weighted graph to a destination node in that graph.
112
Discrete Mathematics & Combinatorics
113
Discrete Mathematics & Combinatorics
114
Discrete Mathematics & Combinatorics
However, currently there is no algorithm to solve this problem with in fewer steps. If the graph is
complete with a n vertices then there are (n-1)! different circuits. For n larger we have closest-
neighbour algorithm, which gives near optimal solution.
Let G =(V, E ,W) be a complete graph with n vertices. The closet- neighbour circuit of G starting
at v1 is (v1, v2, v3,…,vn) got by the following steps.
7 c 12 9 14 b 10
13 5 6 8
d 11 e
115
Discrete Mathematics & Combinatorics
Solution:
Step1: Take one vertex that has small weight to another vertex, i.e. e. Now edge with smallest
weight incident on e is (e, d) =11, (e, c) = 8,(e, b) =5,(e, a) =10 .Now choose (e, b) because it
has minimum weight
Step 2: Now w(b, a) = 14, w(b, c) = 9, w(b, d) = 13, then we choose (b, c) because it has
minimum weight to each other. i.e
b c
Step 3: Now, w(c, e) = 8, w(c, d) = 6, w(c, a) = 12, we choose (c, d) because it has minimum
weight when compare to each other. i.e
b c
d e
Step 4: Now w(d, a) = 7, w(d, b) = 13, w(d, e) = 11, we choose (d, a) because it has minimum
weight when we compare each other. i.e
b c
d e
Step 5: Now w(a, b) = 14 , w(a, c) = 12, w(a, e) = 10, we choose (a, e) because it has
minimum weight when we compare to each other. i.e
b c
d e
116
Discrete Mathematics & Combinatorics
Now we stop to draw the edge because it has form a circle, then the sales man problem of the
above is this
Example 2: Look the following a weighted graph showing monthly lease cost for line in a
computer network.
$2000 New York
$1000
Chicago $800
San Francisco $1200 $1300 $700
$900 $1600 Atlanta
Denver $1400
$2200
Use prim’s algorithm to design a minimum cost communications network connecting all the
computers represented by the graph below.
Solution: we solve this problem by finding spanning tree in the graph in figure above. Prim’s
algorithm is carried out by choosing an initial edge of minimum weight and successively adding
edges of minimum weight that are incident to a vertex in the tree and that do not form simple
circuits.
Chicago
$700
Atlanta
$700 $800
Atlanta
117
Discrete Mathematics & Combinatorics
$700 $800
San-Francisco Atlanta
$900
Denver Atlanta
This graph shows minimum spanning tree produced by Prim’s algorithm with choice made at
each step displayed.
Therefore, the minimum cost communications network connecting all the computers represented
by above graph,
$800+$700+$1200+$900=$3600
Check list
To check your mastery the topic put (√ ) if you can perform it.; otherwise put (X) in front of each
statement.
Important points I Can I Can’t
1. Define weighted graph.
2. Give examples of weighted graph.
3. Define the minimal spanning tree of a weighted graph.
4. Give examples of minimal spanning trees.
5. Find the minimal spanning tree of a weighted graph.
118
Discrete Mathematics & Combinatorics
Exercise
G
2. Prim’s algorithm to find a minimum spanning tree for the given weighted graphs.
G1 G2
3. Determine a railway network of minimal cost for the cities.
119
Discrete Mathematics & Combinatorics
4. Find the length of a shortest path between a and z in the given weighted graph.
120
Discrete Mathematics & Combinatorics
Chapter 5
Chapter Objectives
On completion of this chapter, students will be able to
Network
Let N = (V, E) be a loop-free connected directed graph. Then N is called a network, or transport
network, if the following conditions are satisfied:
i) There exists a unique vertex a ∈V with id(a), the in degree of a, equal to O. This
vertex a is called the source.
ii) There is a unique vertex z ∈V, called the sink, where od(z), the out degree of z,
equals O.
iii) The graph N is weighted, so there is a function from E to the set of non negative
integers that assigns to each edge e = (v, w) ∈E a capacity, denoted by
c(e) = c(v, w).
If N = (V, E) is a transport network, a function f from E to the non-negative integers is called a
flow for N.
121
Discrete Mathematics & Combinatorics
Example: The graph N below is network. Here vertex a is the source, the sink is at vertex z, and
capacities are shown beside each edge. Since c(a, b) + c(a, g) = 5 + 7 = 12, the amount of the
commodity being transported from a to z cannot exceed 12. With c(d, z) + c(h, z) = 5 + 6 = 11,
the amount is further restricted to be no greater than 11.
For the network, the label x, y on each edge e is determined so that x = c(e) and y is the value
assigned for a possible flow f. The label on each edge e satisfies f(e) & c(e).
In part (a) of the network flow, the flow into vertex g is 5, but the flow out from that vertex is 2 +
2 = 4.
Hence the function f is not a flow in this case.
For the network flow in above (b), only the edge (h, d) is saturated. All other edges are
unsaturated.
The value of the flow in this network is
122
Discrete Mathematics & Combinatorics
Consequently, the total flow leaving the source a equals the total flow into the sink z.
In any network, the value of any maximum flow is equal to the capacity of any minimum cut.
Example: Find a maximum flow in the network shown below and prove that it is a maximum.
N
Solution: We start by sending a flow of 2 units through the path sadt, a flow of 3 units through
sbet, and a flow of 3 units through scft, obtaining the flow shown on graph A below.
Continue by sending flows of 2 units through sbdt and 2 units through sbft, obtaining the flow
shown on graph B below.
A B
At this point, there are no further flow-augmenting chains from s to t involving only forward
arcs.
123
Discrete Mathematics & Combinatorics
However, we can use the backward arc da to obtain a flow-augmenting chain scbdaet. Since the
slack of this chain is 2, we add a flow of 2 to sc, cb, bd, ae, and et, and subtract 2 from ad. The
result is shown in graph C below.
C
A search for further flow-augmenting chains takes us from s to c or b and on to d, where we are
stuck.
This tells us that the current flow (of value 14) is maximum.
It also presents us with a cut verifying maximality, namely, S = {s, b, c, d} (those vertices reachable
from s by flow-augmenting chains) and T = {a, e, f, t} (the complement of s).
The capacity of this cut is
Csa + Cbe + Cbf + Ccf + Cdt = 2 + 3 + 2 + 3 + 4 = 14.
Since this is the same as the value of the flow, we have verified that our flow is maximum.
Example 2: In the network given below
124
Discrete Mathematics & Combinatorics
It holds at e because
It holds at d because
125
Discrete Mathematics & Combinatorics
Exercise
1. Determine which of the graphs are networks.
a
a 4 t 2 4
1 2 b 2 s 4 t
s 3 c 5 b 6
G H
•b •t
1 2 0
s 0 •a •c
4 5
d•
a• (5, 2) •c
s• •t
b• (2 , 1) •d
126
Discrete Mathematics & Combinatorics
127
Discrete Mathematics & Combinatorics
Reference:
128