18cs36 - Discrete Mathematical Structures-Notes
18cs36 - Discrete Mathematical Structures-Notes
18cs36 - Discrete Mathematical Structures-Notes
NOTES OF LESSON
To provide quality education and groom top-notch professionals, entrepreneurs and leaders for different
fields of engineering, technology and management.
To open a Training-R & D-Design-Consultancy cell in each department, gradually introduce doctoral
and postdoctoral programs, encourage basic & applied research in areas of social relevance, and develop
the institute as a center ofexcellence.
To develop academic, professional and financial alliances with the industry as well as the academia at
national and transnationallevels.
To develop academic, professional and financial alliances with the industry as well as the academia at
national and transnationallevels.
To cultivate strong community relationships and involve the students and the staff in local community
service.
To constantly enhance the value of the educational inputs with the participation of students, faculty,
parents andindustry.
Vision
Mission
To keep pace with advancements in knowledge and make the students competitive and capable at the
globallevel.
To create an environment for the students to acquire the right physical, intellectual, emotional and
moral foundations and shine as torch bearers of tomorrow'ssociety.
To develop highly talented individuals in Computer Science and Engineering to deal with real world
challenges in industry, education, research and society.
To inculcate professional behavior, strong ethical values, innovative research capabilities and
leadership abilities in the young minds & to provide a teaching environment that emphasizes depth,
originality and criticalthinking.
Motivate students to put their thoughts and ideas adoptable by industry or to pursue higher studies
leading toresearch.
2. Gain technical knowledge, skills and awareness of current technologies of computer science
engineering and to develop an ability to design and provide novel engineering solutions for
software/hardware problems through entrepreneurial skills.
3. Exposure to emerging technologies and work in teams on interdisciplinary projects with effective
communication skills and leadership qualities.
4. Ability to function ethically and responsibly in a rapidly changing environment by applying innovative
ideas in the latest technology, to become effective professionals in Computer Science to bear a life-long
career in related areas.
Program Specific Outcomes (PSOs)
1. Demonstrate understanding of the principles and working of the hardware and software aspects of
Embedded Systems.
2. Use professional Engineering practices, strategies and tactics for the development, implementation
and maintenance of software.
3. Provide effective and efficient real time solutions using acquired knowledge in various domains.
DISCRETE MATHEMATICAL STRUCTURES
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2018 -2019)
SEMESTER – III
Subject Code 18CS36 IA Marks 40
CREDITS – 04
Fundamentals of Logic: Basic Connectives and Truth Tables, Logic Equivalence – The Laws of 10Hours
Logic, Logical Implication – Rules of Inference. Fundamentals of Logic contd.: The Use of
Quantifiers, Quantifiers, Definitions and the Proofs of Theorems.
Module -2
Properties of the Integers: Mathematical Induction, The Well Ordering Principle – 10 Hours
Mathematical Induction. Fundamental Principles of Counting: The Rules of Sum and
Product, Permutations, Combinations – The Binomial Theorem, Combinations with
Repetition.
Module – 3
Relations and Functions: Relations and Functions: Cartesian Products and Relations, Functions 10 Hours
– Plain and One-to-One, Onto Functions. The Pigeon-hole Principle, Function Composition and
Inverse Functions. Properties of Relations, Computer Recognition – Zero-One Matrices and Directed
Graphs, Partial Orders – Hasse Diagrams, Equivalence Relations and Partitions.
Module-4
The Principle of Inclusion and Exclusion: The Principle of Inclusion and Exclusion, 10 Hours
Generalizations of the Principle, Derangements – Nothing is in its Right Place, Rook
Polynomials. Recurrence Relations: First Order Linear Recurrence Relation, The Second
Order Linear Homogeneous Recurrence Relation with Constant Coefficients.
Module-5
Introduction to Graph Theory: Definitions and Examples, Sub graphs, Complements, and Graph 10
Isomorphism, Vertex Degree, Euler Trails and Circuits , Trees: Definitions, Properties, and Hours
Examples, Routed Trees, Trees and Sorting, Weighted Trees and Prefix Codes
Course outcomes:
After studying this course, students will be able to:
1. Use propositional and predicate logic in knowledge representation and truth verification.
2. Demonstrate the application of discrete structures in different fields of computer science.
3. Solve problems using recurrence relations and generating functions.
4. Application of different mathematical proofs techniques in proving theorems in the courses.
5. Compare graphs, trees and their applications.
Text Books: Grimaldi: Discrete and Combinatorial Mathematics, , 5th Edition, Pearson Education. 2004.
Refernce Books:
1. Basavaraj S Anami and Venakanna S Madalli: Discrete Mathematics – A Concept based
approach, Universities Press,2016
2. Kenneth H. Rosen: Discrete Mathematics and its Applications, 6th Edition, McGrawHill,2007.
3. JayantGanguly: A Treatise on Discrete Mathematical Structures, Sanguine-Pearson,2010.
4. D.S. Malik and M.K. Sen: Discrete Mathematical Structures: Theory and Applications, Thomson,
2004.
5. Thomas Koshy: Discrete Mathematics with Applications, Elsevier, 2005, Reprint2008.
Discrete Mathematical Structures (18CS36)
MODULE 1
Contents
Introduction
Objective
Basic connectivities and truthtables
Logical equivalence- Laws of Logic
Logical Implication- Laws of Inference
Proofs of theorem
Quantifiers.
Assignment Questions
Outcome
Further Reading
Module 1:
1.1. Introduction
This module consists of basic conncetvities where we used to write the truth tables. Further
this module consists of laws of logic where it consists of laws using that we prove the logical
equivalence. It also consists of logical implications; similar to the laws in logics we have inference
rules. By using this we solve the inference problems.
Quantifiers are the statement which consists of for all and for some values. By using
quantifiers we will solve the truthness of the compound statement. Finally we conclude with the
proofs of theorems with direct proof, indirect proof and proof by contradiction.
Objective
Understand the concept of basic connectvities and truthtable.
Many times while working on a project after the beginning steps, we always have a doubt
regarding whether the direction followed is right or wrong? Are we doing the job correctly?
Whether the decisions taken are correct or incorrect etc? It is here plays an important role;
Using which one can solve a problem with lot of confidence and satisfaction. With these few
remarks, the next sections introduce formal symbolic logic. .
is assigned a symbol “T”or“1”. If the primitive statement is false, it is assigned the symbol ―F”
or “0‖. In view of this, a proposition may be defined as a pair either (p, T) or (p, F).
This situation may be compared to what we discussed earlier in set theory. It is seen that
with respect to a set A and an element x, there are only two options; either x is an element of A or
x need not be an element of A. There too we used the numbers 1 and 0 to describe the situation.
The following are examples ofpropositions:
p: Dr. Manmohan Singh is the president of India.
q: Mumbai is the financial capital of India
r: Bangalore is the silicon valley of India.
s:3+3=5
• x+3 is aninteger.
• Please comein!
• Are u alright? Complete work todayitself
• What are youdoing?
• What a beautifulevening!
These are not considered as propositions. Because, x + 3 is an integer cannot be a proposition, as
x is not specified. A statement of this kind is called an open statement. the statement gets a meaning
only when x is assigned a value chosen from the universe of discourse of the problem considered.
Others are either commands, or enquiries, or exclamatory sentences. These are not
referred to as non-propositions.
Discussion of various logical connectives
Negation: Let p be a proposition. It is not the case that p is called as negation of the p.
.
Simply, it is NOT p . This is denoted by the symbol Øp. This situation can well be explained
by using a truth table which is shown below:
P Øp p Øp
T F 1 0
F T 0 1
p q p Uq
T T T
T F T
F T T
F F F
Note: Logical operator is similar to the union operator in the case of set theory.
Conjunction
p q p ∩q
T T T
T F F
F T F
F F F
Note: Logical operator is similar to the intersection operator in the case of set theory. Also,
logical OR and logical AND have dual characteristics. Thus, conjunction and disjunction are
examples of dual operators.
One sided implication or logical IMPLICATION or IF THEN :
Let p andq be simple propositions. A proposition obtained by combining p and q using
logical connective, namely, one sided IMPLICATION Called pimplies q . It is denoted by
p→q . The truth value of p →q is false only when p is true but q is a false proposition. In
all other instances, p →q is a true statement. The truth table is given below.
P q p→q
0 0 1
0 1 1
1 0 0
1 1 1
Few examples:
• If 3+3=7, then Sunday is a Christmas is aholiday.
• If 3+2 = 5, then sun raises in theeast.
p q P<->q
T T T
T F F
F T T
F F F
.
Note: Here, p is necessary and also sufficient for q. p bi-conditional q is to be read as p if and
only if q.
Exclusive logical OR:Consider two propositions ,say, p and q.Then p exclusive or
q isa compound proposition whose true value is false when both p and q have the same
truth values. Otherwise, the truth value is true. It is denoted by pUq. The truth table is given
below.
.
p q pUq
T T F
T F T
F T T
F F F
Note:This logical operator is similar to the symmetric difference operation for sets.
•
• p U[(q →r )UØq]
• ( p Uq ) →[(q →r ) U(Øq)
n
Hence, the truth table of the formula willcontain rows.
2
What is meant by Tautology? Consider a statement,say
A : A ( p1,p2,p3, . . . pk, ,U,Ú, ® , , Ø) . If for each of the 2koptions, truth value of A turns out to be
true, then A is called a tautology, or as universally accepted formula, or as universally valid
formula, Thus, if a statement formula A is always true, then it said to be a tautology. Suppose, the
truth value of A is always false, then it is called an absurdity, or contradiction, or universally
invalid formula. On the other hand, if the truth value of A is some times true and at others false,
then it is calledcontingency.
Illustrative examples: By constructing the truth table of the following, determine which one is a
tautology? Which one is a contradiction? Which is one a contingency?
1. ( p →q)U( ØpÚq)
2. (p →q)U(Øq→Øp)
p q A : p →q Øp B : ØpUq AB
T T T F T T
T F F F F T
.
F T T T T T
F F T T T T
.
p q A : p →q Øp Øq B : Øq→Øp AB
T T T F F T T
T F F F T F T
F T T T F T T
F F T T
T T T
(a) For practicing her serve daily is a sufficient condition for Ms. SaniaMirzato have a good
chance of winning the Australian Open tennistournament.
(b) Fix my air-conditioner or I won‘t paytherent.
(c) Manavi will be allowed to sit on Mohan‘s motor bike only if she wears herhelmet.
Solution :( a) If Ms. SaniaMirza practices her serve daily, then she will have a good chance of
winning the tennis tournament.
(b) If you do not fix my air-conditioner, then I shall not pay the rent.
(c) If Manaviis to be allowed on Mohan‘s motor bike, then she must wear her helmet as true, and
s Ú t as false. Thus, truth values of these primitive statements are:
The implication is given to be fse;we must have ( pUq ) Ur as true and sÚtasfalse.
Thus, truth values of these primitive statements are:
.
Primitive
statements p Q r s t
T T T T T
Truth values
T T T F F
Harold finishes his data structures project but fails to graduate at the end of semester.
Write the converse, inverse and contra -positive of the statement “If today is a labor day,
then tomorrow is Tuesday”.
Solution:
• The converse statement is ―If tomorrow is Tuesday, then today is LaborDay―.
• The inverse statement is ―If today is not Labor Day, then tomorrow isnotTuesday‖.
• The contra-positive statement is ―If tomorrow is not Tuesday, then today is not Labor
Day
Laws oflogic:
pUp =p (idempotent law)
pUq =q Up (Commutative law)
( pUq )Ur =p U(q Ur) (Associative law)
pUF =F (identity law)
( )
Thus, a set of propositions, U is a discrete structure
With respect to combination of conjunction operator i.e. logical AND operator disjunction
operator i.e. logical OR (U) , we can generate distributive laws. Thus,
isanother discrete structure where . P denotes the setof propositions.
.
Example: Show that (p ∩q) →q is a tautology
Implication Law
Commutative Law
Distributive Law
hypotheses
n2=(2k+1)
2
( ) ( )
2=4k2+4k+1=2 2k2+2k +1=2m+1wherem= 2k2+2k ,aninteger
Thus, n is odd . To prove the converse, we shall give an indirect proof. To begin with let
n2be an odd integer. To prove that nis odd. Suppose on the contrary that let nbe aneven
integer.Thenwecanwriteas
2 2 2
( ) 2
n=2ksothatn = (2k) =4k =2 2k aneveninteger. But this is against
our hypothesisthat n2 is odd. Hence, we conclude that n is anoddinteger.
Let n be an integer. Prove that n is even if and only if 31n +12 is even.
Proof: Suppose that n is an even integer, Thus, n = 2k , where k is an integer.Therefore,
.
31n + 12 = 31×2k = 62k = 2×(31×k ) is even. On the other hand suppose that 31n +12 is even.
To prove that n isan even integer. We shall prove this by giving an indirectproof.Suppose
on the contrary, let n be odd. Then we can write n = 2k +1, where k is an integer. Thus,
• There is at least one student in some engineering watching this programme coming live
from VTU studio, Bangalore.
• Pythagoras Theorem holds well for all right angled triangles and the list go on.
Statements shown in previous slides can be expressed symbolically using quantifiers.
com
.
There are two types of quantifiers:
2. Existential Quantifier: There .are statements which are true only under circumstances. These
statements may be symbolically expressed in terms of existential quantifier, denoted by$ .
Consider an open statement of the form q( x) . Suppose that this statement is true only for some
values of x . This may be symbolically written as $ x q ( x)
3. Note: An open statement of the form q ( x) gets A meaning only when x is replaced by a proper value
from the universe or universe of discourse, denoted by U .
Examples:Examples:Consideruniverseofdiscourseasthesetofalldaysofaweek.ThenU=
{Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}. Consider the statement p ( x)
: xis a holiday . It is known that there is a day in a week which is declared as a general holiday (i.e.
Sunday), thus, this situation may be written as $ x p ( x)
Another example; Take the universe as the set of all flowers and consider the statement,
―Flowers arebeautiful‖. To write this statement in symbolic form, we shall set up
f( x ) : x is a flower , then above may be written symbolically as " x f ( x) . .
Tutorial on Quantifiers:
For the universe of integers, let p ( x), q ( x ), r ( x ), s ( x ), t ( x) be the following open
statements.
p( x) : x >0
q( x) : x is even
r( x) : x is a perfect square
s( x) : x is exactly divisible by 4 t
( x) : x is exactly divisible by 5
AssignmentQuestions
Outcome
1. Verify the correctness of an argument using propositional and predicate logic and truth
tables.
2. Construct proofs using direct proof, proof by contradiction, and indirectproof.
FurtherReading
1. Ralph P. Grimaldi: Discrete and combonotorial Mathematics, 5 thEdition,Pearson
Education2004.
2. Basavaraj S Anami and venkanna S Madalli: Discrete Mathematics – A Concept based
approach UniversitiesPress,2016.
3. Kenneth H. Rosen: Discrete Mathematics and its Applications, 6th Edition, McGraw Hill
2007.
5. D.S. Malik and M.K. Sen: Discrete Mathematical Structures: Theory and Applications,
Thomson,2004.
Module – II
STRUCTURE
Introduction
Objective
Mathematical Induction
Recurrence Relation
The Rules of Sum and Product
The Rule of Sum
The Rule of Product
Permutation
Combination
Combination with Repetitions
Assignment Questions
Outcomes
Further Reading
Introduction
This module gives the overview of principle of counting which consists of permutation and
combination. This is used for learning the arrangements and selection of a given problem. It also
consists recursive definitions and mathematical induction.
objectives
Mathematical induction
Definition
Step 1(Base step): It proves that a statement is true for the initial value.
Step 2(Inductive step): It proves that if the statement is true for thenth iteration (ornumber n),
then it is also true for (n+1)th iteration ( or number n+1).
How to Do It
Step 1: Consider an initial value for which the statement is true. It is to be shown thatthe
statement is true for n=initial value.
Step 2: Assume the statement is true for any value ofn=k. Then prove the statement istrue for
n=k+1. We actually break n=k+1 into two parts, one part is n=k (which is already proved) and
try to prove the other part
Problem 1
n
3 -1 is a multiple of 2 for n=1, 2, ...
Solution
The first part (2×3k) is certain to be a multiple of 2 and the second part (3 k -1) is also
Problem 2
1 + 3 + 5 + ... + (2n-1) = n2
Solution
2
Step 1: For n=1, 1 = 1 , Hence, step 1 is satisfied.
2
Hence, 1 + 3 + 5 + ... + (2k-1) = k is true (It is an assumption)
2
We have to prove that 1 + 3 + 5 + ... + (2(k+1)-1) = (k+1) also holds 1 + 3 + 5
+ ... + (2(k+1) – 1)
= 1 + 3 + 5 + ... + (2k+2 – 1)
= 1 + 3 + 5 + ... + (2k + 1)
Problem 3
Solution
RECURRENCE RELATION
In this chapter, we will discuss how recursive techniques can derive sequences and be used for
solving counting problems. The procedure for finding the terms of a sequence in a recursive
manner is called recurrence relation. We study the theory of linear recurrence relations and their
solutions. Finally, we introduce generating functions for solving recurrence relation.
Definition
A recurrence relation is an equation that recursively defines a sequence where the next term is a
function of the previous terms (Expressing Fn as some combination of Fi with i<n).
Example: Fibonacci series: Fn= Fn-1+ Fn-2, Tower of Hanoi: Fn= 2Fn-1+ 1
A linear recurrence equation of degree k is a recurrence equation which is in the format xn= A1
xn-1+ A2 xn-1+ A3 xn-1+... Akxn-k (An is a constant and Ak≠0) on a sequence of numbers as a
first-degree polynomial.
relations
Suppose, a two ordered linear recurrence relation is: Fn = AFn-1 +BFn-2 where A and B are real
numbers.
x2 − Ax − B = 0
Case 1: If this equation factors as (x- x1)(x- x1) = 0 and it produces two distinct realroots x1 and
x2, then Fn = ax1n+ bx2n is the solution. [Here, a and b are constants]
Case 2: If this equation factors as (x- x1)2= 0 and it produces single real root x1, thenFn = a
x1n+ bn x1n is the solution.
Case 3: If the equation produces two distinct real roots x1and x2in polar form x1= r∠θand x2=
r∠(-θ), then Fn= rn(a cos(nθ)+ b sin(nθ)) isthe solution.
Problem 1
Solution
x2 – 5x + 6=0,
x1 = 3 and x2= 2
The roots are real and distinct. So, this is in the form of case 1
Fn = ax1n+ bx2n
Problem 2
Solution
So, (x – 5)2 = 0
Hence, there is single real root x1 = 5
Fn = ax1n + bnx1n
cannot be performed in continuously, then performing either task can be accomplished in any
ofm+n ways .
Example 1:
A College library has40textbook on sociology and 50 textbooks dealing with anthropology. By the
rule of sum, a student at this college can select among 40 + 50 = 90 textbooks in order to learn
more about one or the other of these two subjects.
Example 2
The rule can be extended beyond two tasks as long as no pair of tasks can occur simultaneously.
For instance, a computer science instructor who has, say, seven different introductory books each
on C++, Java and Perl can recommend any one of these 21 books to a student who is interested in
learning a first programming language.
Example 3
Suppose a university representative is to be chosen either from 200 teaching or 300 nonteaching
employees, and then there are 200 + 300 = 500 possible ways to choose this representative.
If a procedure can be broken down into first and second stages, and if there are m possible
outcomes for the first stage and if, for each of these outcomes, there are n possible outcomes for
the second stage, then the total procedure can be carried out, in the designated order, in mn ways.
Example 1:
The drama club of Central University is holding tryouts for a spring play. With six men and eight
Women auditioning for the leading male and female roles, by the rule of product the director can
Example 2:
A tourist can travel from Hyderabad to Tirupati in four ways (by plane, train, bus or taxi). He can
then travel from Tirupati to Tirumala hills in five ways (by RTC bus, taxi, rope way, motorcycle
or walk). Then the tourist can travel from Hyderabad to Tirumala hills in 4 X 5 = 20 ways.
Permutations
Continuing to examine applications of rule of product, we turn now to counting linear arrangements
of objects. These arrangements are often called permutations when the objects are distinct. We shall
!
P(n,r)=( − )!
Example 1
The number of words of three distinct letters formed from the letters of word ―JNTU‖ is P (4, 3)
= 4!/(4 - 3)!=24. If repetitions are allowed, the number of possible six – letter sequence is 46
=4096
Example 2:
In how many ways can eight men and eight women be seated in a row if (a) any person may sit
next to any other (b) men and women must occupy alternate seats (c) generalize this result for n
men and n women. Here eight men and eight women are 16 indistinguishable objects.
c) Any person may sit: (2n)! Men and women sit alternatively: 2(n!) 2
Example 3
The MASSASAUGA is a brown and white venomous snake indigenous to North America.
arranging all of the letters in MASSASAUGA.
7!
Possible arrangements are =840
3!
Among these are In which all four A‘s are together. To get this last result, we considered all
arrangements of the seven symbols AAAA (one symbol), S, S, S, M, U, G.
Example 1
A hostess is having a dinner party for some members of her charity committee. Because of the size
of her home, she can invite only 11 of the 20 committee members. Order is not important, so she
can invite ―the lucky 11‖ in C (20, 11) = 20! / (11! 9!) = 167, 960 ways. However, once the 11
arrive, how she arranges them around her rectangular dining table is an arrangement problem.
Unfortunately, no part of theory of combinations and permutations can help our hostess deal with
―the offended nine‖ who were not invited.
Example 2
11! =831600
2!∗3!∗2!∗2!
How many of these arrangements have no adjacent A‘s? When we disregard the A‘s, there are
8!
=5040
2!∗2!∗2!
Ways to arrange the remaining letters. One of these 5040 ways is shown in the following figure,
where the arrows indicate nine possible locations for the three A‘s. Three of these locations can
be selected in c(9,3)= 84 ways, and because this is also possible for all the other 5039
When repetitions are allowed, we have seen that for n distinct objects an arrangement of size r of
these objects can be obtained in n r ways, for an integer r=0. We now turn to the comparable
problem for combinations and once again obtain a related problem whose solution follows from
our previous enumeration principles.
Example 1:
A donut shop offers 20 kinds of donuts. Assuming that there are at least a dozen of each kind when
we enter the shop, we can select a dozen donuts in C (20 + 12 - 1, 12) = C(31, 12) = 141,120,525
ways. (Here n = 20, r = 12.)
Example 2:
In how many ways can one distribute 10 (identical) white marbles among six distinct containers?
Solving this problem is equivalent to finding the number of nonnegative integer solutions to the
equation x1 + x2 + … + x6 = 10. That number is the number of selections of size 10, with repetition,
from a collection of size 6. Hence the answer is C(6 + 10 — 1, 10) = 3003.
Assignment Questions
2) The number of words of three distinct letters formed from the letters of word ―JNTU‖
Outcomes
After completing this module one can do
Further Reading
3. Kenneth H. Rosen: Discrete Mathematics and its Applications, 6th Edition, McGraw Hill
2007.
5. D.S. Malik and M.K. Sen: Discrete Mathematical Structures: Theory and Applications,
Thomson, 2004.
6. Thomas Koshy: Discrete Mathematics with Applications, Elsevier, 2005, Reprint 2008.
7. https://en.wikipedia.org/wiki/Rule_of_product
8. https://en.wikipedia.org/wiki/Hasse_diagram
9. https://math.feld.cvut.cz/habala/teaching/dma-e/book4x.pdf
Module – III
STRUCTURE
Introduction
Objective
Cartesian Product
Functions
Types of functions
Identity function
Constant function
one to one and on to function
Stirling number of the second kind
Pigeon hole Principle
Composition and invertible functions
Hasse Diagram
Assignment Questions
Outcomes
Further Reading
Introduction
This module gives the overview of relations and functions, which consists of Cartesian
product, types of functions and operations on functions such as composition and invertible
functions.
objectives
Understand the concept of relations and functions.
Solve problems involving composition of functions.
Cartesian product
Let A and B be two sets. Then the set of all ordered pairs (a,b), where a∈A and b∈B, is
called the Cartesian Product or Cross Product or Product set of A and B and is denoted
Example:
Note:We can have the product of a set A with itself, and this product is
BXA = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}
Solution:
(A∩B)XC = {(2,3), (2,4), (2,7)} (Calculate the other quantities in the same manner)
Note: If A and B are finite sets, then |AXB| = |A||B|, |BXA| = |B||A|, |AXA| = |A||A|
(Proof of (1) and (5) are given below others left to the reader to prove)
Proof: (1)
(x, y) ∈ Ax(B ∪ C ) ⇔ x ∈ A, y ∈ B ∪ C ⇔ x ∈ A, y ∈ B or y ∈ C
⇔ x ∈ A, y ∈ B or x ∈ A, y ∈ C
(5) ( x, y) ∈ Ax(B − C ) ⇔ x ∈ A, y ∈ B − C ⇔ x ∈ A, y ∈ B , y∉ C
⇔ x ∈ A, y ∈ B , x ∈ A, y ∉ C
⇔ ( x, y) ∈ ( AxB) , ( x, y) ∉( AxC )
⇔ ( x, y) ∈( AxB) − ( AxC )
Hence Ax(B−C)=(AxB)−(AxC)
Let A and B be two sets. Then a subset of AXB is called a binary relation or a relation
from A to B.
Note:
1. If R is relation from A to B, then R is a set of ordered pairs (a,b) where a∈A and b∈B.
2. R is a set of ordered pairs (a,b) where ∈A and b∈B, then R is relation from A to B.
5. If a set A has m elements and B has n elements then the number of relations
from A to B are 2mn
Problem:
Solution:
|AxB| =|A||B| = 9
2. Consider the sets A = {0,1,2} and B = {8,9}. Indicate the following sets of ordered
pairs are relations from A to B.
(a) R1 = {(0,8),(1,8),(2,9)}
(c) R3 = {(1,9),(0,8),(8,0)}
(b)R2 is not a relation, Because the ordered pair (2,2) does not belong to R2.
(c)R3 is not a relation, Because the ordered pair (8,0) does not belong to R3.
Solution:
(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,1),(4,2),(4,3),(
4,4)} Now the relation R is
R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4), (4,4)}
4. Let A = {1,2,3,4,6} and R be the relation on A defined by (a,b)∈R if and only if ais
multiple of b. Write down R as a set of ordered pairs.
Solution:
AxA = {(1,1),(1,2),(1,3),(1,4),(1,6),(2,1),(2,2),(2,3),(2,4),(2,6),(3,1),(3,2),(3,3),
(3,4),(3,6), (6,1),(6,2),(6,3),(6,4),(6,6)}
={(1,1)(1,2)(2,2)(1,3)(3,3),(1,4),(2,4),(4,4),(1,6),(2,6),(3,6),(6,6)}
Function
Note:
Problem:
f = {(2,3),(1,4),(2,1),(3,2),(4,4)}
g = {(3,1),(4,2),(1,1)}
h = {(2,1),(3,4),(1,4),(4,4)}
Solution:
The element 2 in the domain appeared twice as the first element in the function.
The element 2 in domain has no image in the co domain. Hence g is not a function.
All the elements in the domain appeared once in the function hence h is a function.
2. If A = {0,±1,±2,±3} and f:A→R is defined by f(x) = x2-x+1, x∈A, find the range off.
Solution:
3. If f:R→R is defined by f(x) = x2, what is the range of f, what is f(Z)? What is f([2,1])?
solution:
Range = [0,∞)
f(Z) = {0,1,4,9,16,…….}
f([-2,1]) = [4,1]
Types of functions
Identity Function
A function f:A→A such that f(a) = a for every a ∈A is called the identity function on A.
In other words: If the image of every element is itself in a function then it is identity
function.
Example: f = {(1,1),(2,2),(3,3),(4,4),(5,5)}
Constant Function
A function f:A→B such that f(a) = c for every a ∈A is called the constant function on A
On to Function
A function f:A→B is said to be an onto function if for every element b of B there is an
element a of A such that f(a) = b.
f1={(a1,b2),(a2,b3),(a3,b}
f2={(a1,d2),(a2,d1),(a3,d}
f3={(b1,c2),(b2,c2),(b3,c}
f4 = {(d1,b1),(d2,b2),(d3,b1),(d4,b2)}
The given function f1 is one – to – one and onto. Hence it has one – to – one
correspondence.
Every element in A has unique image, hence the function f is one to one. But w in B does
not have preimage in A, hence it is not onto.
The elements 1 and 2 in A has same image, hence the function g is not one to one.
Similarly y and z in B does not have preimage in A, hence it is not onto.
⇒ X = (y + 3)/2
(ii) f(x) = x3
Consider
f(x1)= f(x2)
x13= x23
x1 = x2
Hence f(x) is one – to – one
Let f(x) = y
⇒ x3 = y
⇒ X = (y)1/3
Let x be any real number. Then x is an integer or x lies between two integers. Let x
denote the greatest integer that is less than or equal to x, and x denote the least
Integer that is greater than or equal to x. Then x is called the floor of x and x is called ceiling
of x.
Example:
3.6+4.2= 7.8 = 7
Projection
For sets A and B, let D⊆AxB. Then the function π A:D→A defined by πA(a,b) = a for all
(a,b)∈D is called the projection of D on A, and the function πB:D→B defined by πB(a,b)
Example:
Let A = B = R. Determine πA(D) and πB(D) for each of the following
Solution:
Let A=B=R. Determine πA(D) and πB(D) for each of the following sets D⊆AxB:
1. D = {(x,y)|x=y2, 0 ≤ y ≤ 2}
πA(D) = {x∈R|x=y2, 0 ≤ y ≤
2} πB(D) = {y ∈ R|y2=x, 0 ≤
x ≤ 4}
3. D = {(x,y)|x2 + y2 = 1}
Let A and B be finite sets with |A| = m and |B| = n, where m≥n. Then the number of onto
functions from A to B is given by the formula Stirling number of the second kind
Note: 1. Given that p(6,4)=1560 and p(7,4)=8400. We can prove that S(6,4) = 65 and
S(7,4) = 350
2. Prove the following: S(5,3) = 25, S(7,2) = 63, S(8,5) = 1050, S(5,4) = 10,
S(8,6) = 266 S(m,1) = 1, S(m,m) = 1 for all m ≥1.
Let A be a nonempty set. Then the function f:A→A is called a unary(or monary)
operation on A.
Result
Results
1. Determine whether the following closed operations f on Z are commutative and /or
assosiative
f(x,y) = x+y-xy
f(x,y)=x+y-1
f(x,y) = xy
= f(y,x)
Hence f is commutative.
= a + z - az
= f(x,y) + z – z f(x,y)
= x + y – xy - z {x + y – xy }
= x + y – xy – zx – zy + xyz …. (1)
= x + b – xb
= x + f(y,z) – x f(y,z)
= x + y + z – yz – x{y + z – yz }
= x + y + z – yz – xy – xz + xyz….(2)
f is associative
(ii) f(x,y) = xy
≠f(y,x)
= az
= f(x,y) z
= xyz --------------------- (1)
f(x,f(y,z)) = f(x, b) where = f(y,z)
= xb
= xf(y,z)
f is associative
Pigeonhole Principle
If m pigeons occupy n pigeonholes, where m>n, then at least one Pigeonhole must contain
two or more pigeons in it.
If m pigeons occupy n pigeonholes, then at least one pigeonhole must contain (p+1) or
more pigeons, where p =[(m-1)/n].
1. ABC is an equilateral triangle whose sides are of length 1cm each. If we select 5
points inside the triangle, prove that at least two points are such that the distance
between them is less than ½ cm.
Solution:
Consider the triangle DEF formed by the midpoints of the sides BC, CA and AB of
the given triangle ABC as shown in the diagram. Then the triangle ABC is partitioned into
four small equilateral triangles each of which has sides equal to ½ cm. Treating each of
these four triangles as pigeonholes and five points chosen inside the triangle as
pigeons, we find by pigeonhole Principle that atleast on triangle must contain two or more
points. Hence, the distance between such points is less than ½ cm.
From the 8 of the 20 students selected, the number of a teams of 3 students that can be
formed is 8C3 = 56
According to the way in which the code number of a team is determined, we note that the
smallest possible code number is 1 + 2 + 3 = 6 and the largest possible code number is 18 +
19 + 20 = 57.
Thus the code numbers vary from 6 to 57 and these are 52 in number.
As such, only 52 code numbers are available consider them as pigeon holes and the 56
teams as pigeons.
By pigeon hole principle at least two different teams will have the same code number.
3. Prove that if 151 integers are selected from the set S = {1,2,3,… ,300}, then the
selection must include two integers x,y where x|y or y|x.
Solution:
Let A = {1,3,5,7,………,299}
Then every integer n between 1 and 300 is of the form n = 2 ka, where k is an integer ≥ 0
The set A has 150 distinct elements and therefore, if 151 elements of S are selected, then at
least two of them say x and y, x≠y must correspond to the same a∈A. Thus, x = 2ma, y =
2na, for some integers m, n ≥ 0.
4. Show that if any seven numbers from 1 to 12 are chosen, then two of them will add to
13. Solution:
These are the only sets containing two numbers from 1 to 12 whose sum is 13. Since
every number from 1 to 12 belongs to one of the above sets, each of the seven numbers
chosen must belongs to one of the sets.
Since there are only 6 sets, two of the seven chosen numbers have to belong the same set.
Considering the 7 sets as pigeons and 6 sets as pigeonholes, by pigeonhole principle the sum
of these two numbers must be equal to 13.
5.Show that if any n+1 numbers from 1 to 2n are chosen, then two of them will have their
sum equal to 2n+1.
Solution:
These are the only sets containing two numbers from 1 to 2n whose sum is 2n + 1.
Since every number from 1 to 2n belongs to one of the above sets, each of the n + 1
numbers chosen must belong to one of the sets.
Since there are only n sets, two of the n + 1 chosen numbers have to belong to the same set.
Considering the 2n + 1 sets as pigeons and 2n sets as pigeonholes, by pigeonhole principle the
sum of these two numbers must be equal to 2n + 1.
If 5 colours are used to paint 26 doors, Prove that at least 6 doors will have the same colour.
Solution:
Composition of Functions
Consider three non-empty sets A, B, C and the functions f:A→B and g:B→C. The
composition of these two functions is defined as the function gοf:A→C with (gοf)(a) = g[f(a)]
=f(x + 5)
=(x + 5)2
= x2 + 10x+ 25 --------(2)
∴ (1) ≠ (2)
2. Let f,g,h be functions from R to R defined by f(x)=x+2, g(x)=x-2, h(x)=3x for all x∈R.
Find gοf, fοg, fοf, gοg, fοh, hοg, hοf, fοhοg
Solution:
=g(x + 2)
=x + 2 – 2=x
=f(x – 2)
=x – 2 + 2
=x
= 3x + 2
Solution:
fοg (x) = f[g(x)] = {(1,3), (2,2), (3,1)} (Find the other quantities) Invertible Functions
A functions f:A→B is said to be invertible if there exists a function g:B→A such that gοf
= IA and fοg = IB, where IA is the identity function on A and IB is the identity function on
B.
Problems
1. Let A={1,2,3,4} and B={a,b,c,d}. Determine whether the following functions from
A to B are invertible or not.
f={(1,a),(2,a),(3,c),(4,d)}
g={(1,a),(2,c),(3,d),(4,d)}
Solution:
x1 + 1 = x2 + 1
x1 = x2
Hence f is one – to –
one Let f(x) = y
x+1=y
x = y – 1∈R
Hence f is onto
Thus f is invertible.
3. Let A = B = C = R, and f:A→B and g:B→C defined by f(a)= 2a+1, g(b)=b/3 for
all a∈A, b∈B. Compute gοf and show that gοf is invertib e. What is (gοf)-1
It is evident that gοf is one – to – one and onto. Hence gοf is invertible.
(gοf)(x) = c
(2x+1)/3 = c
⇒ x = (3c – 1)/2
4. For the functions f and g from R to R given below, verify that (gοf) -1 =f-
1
οg-1 f(x) = 2x, g(x) = 3x – 2
Theorem 1.
Let f:A→B and g:B→C be any two functions. Then the following are true:
Theorem 2.
Let f : A→B, g : B→C and h: C→D be three functions. Then (hοg)οf = hο(gοf)
Theorem 3
Theorem 4
If a function f:A→B is invertible then it has a unique inverse. Further if f(a)=b, then f -
1
(b)=a Theorem 5
Let A and B be finite sets with |A| = |B| and f be a function A to B. Then
the following statements are equivalent
Hasse Diagram
A Hasse diagram is a type of mathematical diagram used to represent a finite partially
ordered set, in the form of a drawing of its transitive reduction.
D36 = { 1,2,3,4,6,9,12,18,36}
The relation R of divisibility (that is aRb if and only if a divides b ) is a partial order on
this.
The hasse diagram for R must exhibit all of the above facts. The diagram is as shown
above.
2. Let R be a realtion on the set A = {1,2,3,4} defined by xRy if and only if x divides y.
Prove that (A,R) is a poset. Draw its hasse diagram?
We verify that the elements of R are such that if (a,b) ∈ R and a ≠ b, then (b,a) ∉ R,
Therefore, R is antisymmetric on A.
Further , We check that the elements of R are such that if (a,b) ∈ R and (b,c) ∈ R then
(a,c) ∈ R. Therefore , A is transitive on A.
R = {(1,1),(1,2),(1,4),(1,3),(1,5),(2,2),(2,4),(3,3),(3,5),(4,4),(5,5)}
Consequently, the matrix of R is given below:
MR =
(This matrix can be written down directly by examining the given Hasse diagram. We
have written down R explicitly to make things clearer).
Assignment Questions
1) If A = {1,2,3,4} , B = {2,5}, C = {3,4,7} write down the following
AXB, BXA, AXC, CXA, BXC, CXB, A∪(BXC), (A∪B)XC, A∩(BXC), (A∩B)XC,
(AXC)∪(BXC), (AXC)∩(BXC)
2) Explain the types of functions.
Outcomes
After completing this module one can
Understand the relations and functions
Solve problems involving composition and invertible function.
Further Reading
1. Ralph P. Grimaldi: Discrete and combonotorial Mathematics, 5th Edition,Pearson Education
2004.
3. Kenneth H. Rosen: Discrete Mathematics and its Applications, 6th Edition, McGraw Hill
2007.
5. D.S. Malik and M.K. Sen: Discrete Mathematical Structures: Theory and Applications,
Thomson, 2004.
6. Thomas Koshy: Discrete Mathematics with Applications, Elsevier, 2005, Reprint 2008.
7. https://en.wikipedia.org/wiki/Rule_of_product
8. https://en.wikipedia.org/wiki/Hasse_diagram
9. https://math.feld.cvut.cz/habala/teaching/dma-e/book4x.pdf
Module – IV
STRUCTURE
Introduction
Objective
Principle Of Inclusion And Exclusion
Dearrangements
Rook Polynomials
Recurrence Relations
Homogeneous
Non Homogeneous
Assignment Questions
Outcomes
Further Reading
Introduction
This module gives the overview of principle of inclusion and exclusion where we find the inclusive
and exclusive elements. Dearrangement nothing in the write place and rook polynomials. It also consist of
recurrence relations with homogeneous and non-homogeneous
objectives
Understand the concept of inclusion and exclusion.
Solve problems involving recurrence relations.
Solving rook polynomial problems.
In this section we develop some notation for stating this new counting principle. Then we establish the
principle by a combinatorial argument. Following this, a wide range of examples demonstrate how this
principle may be applied.
Example 1
Determine the number of positive integers n where 1 n 100 and N is not divisible by 2, 3, or 5.
a) condition c1 if n is divisible by 2.
b) condition c2 if n is divisible by 3, and
c) condition c3 if n is divisible by 5.
(These 26 numbers are 1, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73,
77, 79, 83, 89, 91, and 97.)
Example 2
Find the number of integers between 1 and 10,000 inclusive, which are divisible by none of 5, 6
or 8.
Let P1 be the property that an integer is divisible by 5, P2 the property that an integer is divisible
by 6, P3 the property that an integer is divisible by 8. Let A be the set consisting of the first 10,000
integers. Let Ai be the set consisting of those integers in A with property Pi, for i = 1, 2,
3. The problem is to find the number of integers in A1 A 2 A 3 . Now |A1| = 10,000/5 = 2000,
|A2| = 10,000/6 = 1666, |A3| = 10,000/8 = 1250. Integers in the set A1 A2 are divisible by both 5
and 6. Note that an integer is divisible by both 5 and 6 if it is divisible by their lcm {5, 6} = 30.
Also lcm {5, 8} = 40, lcm {6, 8} = 24. then |A1 A2| = 10,000/30 = 333.|A1 A3| = 10,000/40
=250, |A2 A3| = 10,000/24 =416.
Now by Principle of Inclusion and Exclusion, the number of integers between 1 and 10,000 that
are divisible by none of 5, 6 and 8 equals.
|A1 A2 A3| = |A| – (|A1|+ |A2|+ |A3|) + (|A1 A2|+|A2 A3|+|A3 A1|) – |A1 A2 A3|
6000.
Example 3
Let A be the set of all permutations of the 10 letter given. Let P1 be the property that a permutation
in A contains the word JNU as Conse utive letters, let P2 be the property that a permutation
contains the word IS and let P3 be property that a permutation contains the GREAT. Let Ai be the
set of those perm a ions in A satisfying the property P i for i = 1, 2,
3. The problem is to find the number of perm tations in Now |A| = 10! = 3,628,800. The set A 1
contains the perm a ions of the 8 symbols JNU, I, S, G, R, E, A, T so |A1| = 8!. Similarly A2
contains permu a ions of the 9 symbols J, N, U , IS, G, R, E, A, T so |A2| = 9! = 362,880. Similarly
A3 contains permutations of the 6 symbols J, N, U , I, S, GREAT so |A3| = 6! = 720. Also |A1 A2|
= 7! = 5040, since A1 A2 contains permutations of the 7 symbols JNU, IS, G, R, E, A, T. Also |A1
A3| = 4! = 24, since A1 A3 contains permutations of the 4 symbols JNU, I, S, GREAT. Finally |A1
A2 A3| = 3! = 6, since A1 A2 A3 contains the permutations of the three symbols JNU, IS, GREAT.
Using the Principle of Inclusion – Exclusion we have
| A1uA2uA3 | = 3,628,800 - (40,320 + 362,880 + 720)
+ (5040 + 24 +120) - 6
3,230,058
Example 1
Peggy has seven books to review for the C–H Company, s she hires seven people to review them. She wants
two reviews per book, so the first week she gives each person one book to read and then redistributes the
books at the start of these end week. In how many ways can she make these two distributions so that he gets
two reviews (by different people) of each book?
She can distribute the books in 7! ways the first week. Numbering both the books and the reviews (for the
first week) as 1, 2, . . ., 7, for the e ond di tribution she must arrange
These numbers so that none of them is in its nat ral position. This she can do in d7 ways.
By the rule of product, she can make he wo distributions in (7!)d7 = (7!)2(e-1) ways.
DEPARTMENT OF CSE, ATMECE page 5
DISCRETE MATHEMATICALSTRUCTURES(18CS36)
1 1 1 n 1
For example
D2 = 2! 1- 11 +! 1 2=! 1
1 1 1 1 1
D3 = 3! 1 - + - = 6 1 -1+ - =2
1! 2! 3! 2 6
Example 2
A machine that inserts letters into envelopes goes haywire and inserts letters randomly into envelopes. What
is the probability in a group of 100 letters (a) no letter is put into the correct envelope (b) exactly 1 letter is
put into the correct envelope (c) exactly 98 letters are put into the correct envelope (d) exactly 99 letters are
put into the correct envelope (e) all letters are put into the correct envelopes?
a) The probability of no letter being p t in the orrect envelope is D n/100! Because the number of
favorable cases (the derangements) is Dn and the total number of favorable cases is n! = 100!.
Example 3
a) List all the derangements of the numbers 1, 2, 3, 4, 5 where the first three numbers are 1,
2, 3 in order.
b) List all the derangements of the numbers 1, 2, 3, 4, 5, 6 where the first three numbers are 1, 2, 3 in
some order.
c) When 1, 2, 3 are in some order, there are only two derange ents (i) 23,154 and (ii) 31, 254 (other
examples include 21,354 and 32,154)
d) There are only for such derangements. For example, ne such set is (i) 231,546 (ii) 312,546 (iii)
231,645 (iv) 312,645 (other example in lude (i) 213,546 (ii) 321, 546 (iii) 213,645 (iv) 321,645)
Rook Polynomials
Consider the six-square ―chessboard‖ shown in Figure (Note: The shaded squares are not part of the
chessboard.) in chess a piece called a rook or castle is allowed at one turn to be moved horizontally or
vertically over as many unoccupied spaces as one wishes. Here a rook in square 3 of the figure could be
moved in one turn to squares 1, 2, or 4. A rook at square 5 could be moved to square 6 or square 2 (even
though there is no square between squares 5 and 2).
5 6
For k Z+ we want to determine the n mber of way in which k rooks can be placed on the unshaded squares
of this chess-board so that no two of them can take each other–that is, no two of them are in the same row
or col mn of the chessboard. This number is denoted by r k or by rk (C) if we wish to stress ha we are working
on particular chessboard C.
For any chessboard, r1 is the number of sq ares on the board. Here r 1 = 6. Two nontaking rooks can be
placed at the following pairs of positions: {1, 4}, {1, 5}, {2, 4}, {2, 6}, {3, 5}, {3, 6}, {4, 5} and {4, 6},
so r 2 = 8 Continuing, we find that r3 = 2, using the Locations {1, 4, 5} and {2, 4, 6}; r k = 0, for k 4
With r0 = 1, the rook polynomial, r (C, x), for the chessboard in Fig 8.6 is defined as r (C,
x) = 1 + 6x + 8x2 + 2x3. For each k 0, the coefficient of xk is the number of ways we can place k
nontaking rooks on chessboard C.
What e have done here (using a case-by-case analysis) soon proves tedious. As the size of the board
increases, we have to consider cases wherein numbers such as r 4 and r5 are nonzero. Consequently, we shall
now make some observations that will allow us to make use of small boards and somehow break up a large
board into smaller subboards.
The chessboard C in Fig 8.7 is made up of 11 unshaded square. We note that C consists of a 2 X 2 subboard
C1 located in the upper left corner and a seven-square subboard C2 located in the in the lower right corner.
These subboards are disjoint because they have no squares in the same row or column of C.
Hence r(C, x) = r(C1, x) . r(C2, x). B did his occur by luck or is something happening here that we
should examine more closely? For example, to obtain r 3 for C, we send to know in how many ways
three nontaking rooks can be placed on board C.
a) All three rooks are on subboard C2 (and none is on C1): (2)(1) = 2 ways.
Consequently, three nontaking rooks can be placed on board C in (2)(1) + (10)(4) + (7)(2) = 56
ays. Here e see that 56 arises just as the coefficient of x3 does in the product r(C1, x) . r(C2, x).
In general, if C is a chessboard made up of pairwise disjoint subboards C 1, C2, . . . , Cn, then r(C,
x) r(C2, x) . . . r(Cn, x).
DEPARTMENT OF CSE, ATMECE page 11
DISCRETE MATHEMATICALSTRUCTURES(18CS36)
The last result for this section demonstrates the type of principle we have seen in other results in
combinatorial and discrete mathematics: Given a large chessboard, break it into smaller subboards
whose rook polynomials can be determined by inspection.
Consider chessboard C in Figure. For k 1, suppose we wish to place k non taking rooks on C. For
each square of C, such as the one designated by (*), there are two possibilities to examine.
a) Place one rook on the designated square. Then we remove, as possible locations for the other
k – 1 rooks, all other squares of C in the same row or column as the designated square. We use C s
to denote the remaining smaller subboard [seen in Fig.8.8 (b)].
b) We do not use the designated square at all. The k rooks are placed on the sub board Ce [C with
the one designated square eliminated –– as shown in the Fig. 8.8(c)].
If n is the number of squares in the chessboard (here n is 8), Then Eq. (1) is valid for all 1
k n, and we write
n N N
For Eq.(2) we realize that the summations may stop before k = n. We have seen cases, as in Fig.
8.6, where rn and some prior rk‘s are 0. The summations start at k = 1, for otherwise we could find
ourselves with the term r- 1(Cs)x0 in the first summand on the right-hand side of Eq. (2).
n N n
We now use this final equation to determine the rook polynomial for the chessboard shown in part
(a) of Figure .Each time the idea in Eq. (4) is used, we mark the special square we are using with
(*). Parentheses are placed about each chessboard to denote the rook polynomial of the board.
= x2 (1+ 2x) + 2x(1+ 4x + 2x2 ) + x(1+ 3x + x2 )
= 1+ 8x +16x2 + 7x3.
Assignment questions
1. Define dearrangents. Find the number of deaarangents of 1,2,3,4 using exponential
technique.
2. Determine the number of positive integers 1-100 and not divisible by 2 or 3 or 5.
Outcomes
After completing this module one can do
1) Solve rook polynomial problems
2) Understand inclusion and exclusion principle.
3) Solving recurrence relation.
Further Reading
1. Ralph P. Grimaldi: Discrete and combonotorial Mathematics, 5th Edition,Pearson Education
2004.
3. Kenneth H. Rosen: Discrete Mathematics and its Applications, 6th Edition, McGraw Hill
2007.
5. D.S. Malik and M.K. Sen: Discrete Mathematical Structures: Theory and Applications,
Thomson, 2004.
6. Thomas Koshy: Discrete Mathematics with Applications, Elsevier, 2005, Reprint 2008.
7. https://en.wikipedia.org/wiki/Rule_of_product
8. https://en.wikipedia.org/wiki/Hasse_diagram
9. https://math.feld.cvut.cz/habala/teaching/dma-e/book4x.pdf
Module – V
STRUCTURE
Introduction
Objective
Introduction
Types of graphs
Directed graphs
Sub graphs
Isomorphism
The Konigsberg Bridge Problem
Trees
Assignment Questions
Outcomes
Further Reading
Introduction
This module gives the overview of Graphs and Trees, which consists of finding the in
degree outdegree, types of graphs and trees.it also includes finding the optimal prefix code for the
tree.
objectives
Understand the concept of graphs and trees.
Solve problems involving graphs and trees.
INTRODUCTION :
This topic is about a branch of discrete mathematics called graph theory. Discrete
mathematics – the study of discrete structure (usually finite collections) and their properties
include combinatorics (the study of combination and enumeration of objects) algorithms
for computing properties of collections of objects, and graph theory (the study of objects
and their relations).
Many problem in discrete mathematics can be stated and solved using graph theory therefore
graph theory is considered by many to be one of the most important and vibrant fields within
discrete mathematics.
A B
C D
Observe that this definition permits an edge to be associated with a vertex pair (vi , vj) such
an edge having the same vertex as both its end vertex comes is called a self-loop.
Edge e1 in fig (a) is a self-loop. Also note that the definition all has more than one edge
associated with a given pair of vertices, for example, edges e 4 and e5 in fig (a), such edges
are referred to as ‗parallel edges‘ graph that has neither self-loops nor parallel edges is
called a ‗simple graph‘.
Since the left hand side in equation (1.2) is even, and the first expression on the right hand
side is even (being a sum of even numbers), the second expression must also be even
Because in equation (1.3) each d(vk) is odd, the total number of terms in the sum must be
Types of graphs
A graph in which all vertices are of equal degree is called a „regular graph‟ (or simply a
regular).
DEFINITION:
A vertex having no incident edge is called an ‗isolated vertex‘. In other words, isolated vertices
are vertices with zero degree are isolated vertices a vertex of degree one is called a pendent
vertex or an end vertex is a pendent vertex. Two adjacent edges are said to be in series if their
common vertex is of degree two.
In the definition of a graph G = (V, E), it is possible for the edge set E to be empty. Such a
graph without n edge is called a ‗null graph‟. In other words, every vertex in a null graph is
an isolated vertex. Although the edge set E may empty the vertex set V must not be empty;
otherwise there is no graph. In other words, by definition, a graph must have at least one vertex.
SIMPLE GRAPH :
A graph which does not contain loops and multiple edges is called simple graph.
COMPLETE GRAPH :
A simple graph of order 2 in which there is an edge between every pair of vertices is
called a complete graph (or a full graph). In other words a complete graph is a simple
graph in which every pair of distinct vertices are adjacent.
BIPARTITE GRAPH
Suppose a simple graph G is such that its vertex set V is the union of two of its mutually
disjoint non-empty subsets V1 and V2 which are such that each edge in G joins a vertex
inV1 and a vertex inV2.Then G is called a bipartite graph. If E is the edge set of this
graph, the graph is denoted by G = (V1, V2: E), or G = G(V1, V2: E). The sets V1and V2
are called bipartites (or partitions) of the vertex set V.
DIRECTED GRAPHS :
Look at the diagram shown below. This diagram consists of four vertices A, B, C, D and
three edges AB,CD,AC with directions attached to the .The directions being indicated by
arrows.
A directed graph (or digraph) is a pair (V,E), where V is a non empty set and E is a set of
ordered pairs of elements taken from the set V.
For a directed graph (V, E), the elements of V are called Vertices (points or nodes) and
the elements of E are called “Directed Edges”. The set V is called the vertex set and the
set E is called the directed edge set
by D=(V,E) or D =D(V,E).
The geometrical figure that depicts a directed graph for which the vertex set is
E={AB,CD,CA}={(A,B),(C,D),(C,A)}
If V is the vertex of a digraph D, the number of edges for which V is the initial vertex is
called the outgoing degree or the out degree of V and the number of edges for which V is
the terminal vertex is called the incoming degree or the in degree of V. The out degree of
V is denoted by d+ (v) or o d (v) and the in degree of V is denoted by d - (v) or i d(v).
It follows that
For the digraph shown in figure the out degrees and the in degrees of the vertices
are as given
below
V2 V3
V5
+ -
d (v1) = 2 d (V1) = 1
+ -
d (v2) = 1 d (v2) = 3
+ -
d (v3) = 1 d (v3) = 2
+ -
d (v4) = 0 d (v4) = 0
+ -
d (v5) = 2 d (v5) = 1
+ -
d (v6) = 2 d (v6) = 1
We note that ,in the above digraph, there is a directed loop at the vertex v3 and
+ -
this loop contributes a count 1 to each of d (v3) and d (v3) .
We further observe that the above digraph has 6 vertices and 8 edges and the
sums of the out-degrees and in-degrees of its vertices are
d (v j d(vi
Example 1: Find the in- degrees and the out-degrees of the vertices of the digraph shown in
Figure
vertices V1 V2 V3 V4 V5
D+ 1 1 1 3 1
d- 1 1 1 2 2
Handshaking property :
Let us refer back to degree of the graph shown in figure we have, in this graph,
Property: The sum of the degrees of all the vertices in a graph is an even number, and this
number is equal to twice the number of edges in the graph.
This property is obvious from the fact that while counting the degree of vertices, each
edge is counted twice (once at each end).
In an alternative form, this property reads as follows:
Because, it essentially states that if several people shake hands, then the total number of
hands shaken must be even, because just two hands are involved in each hand shake.
Proof : Consider a graph with n vertices. Suppose K of these vertices are of odd degree so
that the remaining n-k vertices are of even degree. Denote the vertices with odd
degree by V1,V2,V3,…….,Vk and the vertices with even degree by Vk+1,Vk+2,…..,vn then
n k n
deg vi vi deg vi
i ik
In view of the hand shaking property, the sum on the left hand side of the above expression is
equal to twice the number of edges in the graph. As such, this sum is even. Further, the second
sum in the right hand side is the sum of the degrees of the vertices with even degrees. As such
this sum is also even. Therefore, the first sum in the right hand side must be even; that is,
deg(V1) + deg(V2) + -- + deg (Vk) = Even—(ii)
But, each of deg(V1), deg(V2),…….,deg (Vk) is odd. Therefore, the number of terms in the left
hand side of (ii) must be even; that is, K is even
Example : For the graph shown in fig 1.15 indicating the degree of each vertex and verify the
handshaking property
a
b
g
c
e
deg (a) = 1, deg (b) = 2, deg (c) = 4, deg (d) = 2, deg(f) = 1, deg (e) = 2, deg (g) = 2
We note that e is an isolated vertex and h is a pendant vertex.
Further, we observe that the sum of the degrees of vertices is equal to 16. Also, the graph has
8 edges. Thus, the sum of the degrees of vertices is equal to twice the number of edges.
This verifies the handshaking property for the given graph.
SUBGRAPHS
Given two graphs G and G1, we ay that G1 is a sub graph of G if the following
conditions hold:
Essentially, a sub graph is a graph which is a part of another graph. Any graph isomorphic to a
sub graph of a graph G is also referred to as a sub graph of G.
Consider the two graphs G1 and G shown in figures 1.16(a) and 1.16(b) respectively, we
observe that all vertices and all edges of the graph G1 are in the graphs G and that every edge
in G1 has same end vertices in G as in G1.Therefore G1 is a sub graph of G .In the diagram of
G ,the part G1 is shown in thick lines.
The following observation can be made immediately.
ii) Every simple graph of n vertices is a sub graph of the complete graph Kn.
For example, for the graph shown in figure1, the graph shown in figure 2 is a spanning
subgraph whereas the graph shown in figure 3 is a subgraph but not a spanning subgraph
INDUCED SUBGRAPH
Given a graph G=(V,E), suppose there is a subgraph G1=(V1,E1) of G such that every edge
{A,B} of G, where AB V1 is an edge of G1 also .then G1 is called an induced subgraph of G
(induced by V1) and is denoted by < V1 >.
COMPLEMENT OF A SUBGRAPH
Given a graph G and a subgraph G1 of G, the subgraph of G obtained by deleting from all the
edges that belongs to G1 is called the complement of G1 in G; it is denoted by G-G1 or G1
In other ords ,if E1 is the set of all edges of G1 then the complement of G1 in G is given by G1
= G-E1.We can check that G1=G-G1.
For example :
Consider the graph G shown in figure 1.Let G1 be the subgraph of G shown by thick lines in
this figure. The complement of G1 in G, namely G1, is as shown in figure 2
Earlier we have noted that every simple sub graph of order n is a subgraph of the complete graph
Kn .If G is a simple graph of order n ,then the complement of G in K n is called the complement
of G, it is denoted by G. Thus, the complement G of a simple graph G with n vertices is that graph
which is obtained by deleting those edge of Kn which belongs to G. Thus G =Kn-G =Kn- G.
Evidently Kn, G and G h ve the same vertex set and two vertices are adjacent in G if and only
if they are not adjacent in G. Obviously, G is also a simple graph and the complement of G is
G that is G = G
In figure the complete graph K4 is shown. A simple graph G of order 4 is shown in figure The
complement G, of G is shown in figure
Observe that G, G & K4 have the same vertices and that the edges of G are got by deleting
those edges from K4 which belong to G.
Fig. (b)F:iG
g. (a):
K4 Fig. (b): G
Fig. (c): G
Consider a connected graph G. If there is a circuit in G that contains all the edges of G. Than
that circuit is called an Euler circuit (or Eulerian line, or Euler tour) in G. If there is a trail in
G that contains all the edges of G, than that trailcomisalled an Euler trail.
Recall that in a trail and a circuit no edge can appear more than once but a vertex also. can
appear more than once. This property is carried to Euler trails and Euler Circuits
Since Euler circuits and Euler trails include all edge, then automatically should include all
vertices as well. A connected graph that contains an Euler circuit is called a Semi Euler graph
(or a Semi Eulerian graph).
1. Find all positive integers n (>=2) for which the complete graph K n contains an euler circuit. For
which n does Kn have an euler trail but not an euler circuit?
n contains exactly one edge. This edge together with its end vertices
constitiutes an euler trail. In this case Kn cannot have an euler ciruit. For n>=3, Kn contains
an euler circuit if and only if n-1 (which is the degree of every vertex in Kn) is even; that is
if and only if n is odd.
ISOMORPHISM
f : V,V‘ such that (i) f is a none to one correspondence and(ii) f r all vertices A, B of G
{A, B} is an edge of G if and only if { f(A), f(B)} is an edge of G‘, then f is called
as isomorphism between G and G‘, G and G‘ are isomorphic graphs.
In other words, two graph G and G‘ are said to be isomorphic (to each other) if there is a one
to one correspondence between their vertices and between their edges such that the
adjacency of vertices is preserved such graphs will have the same structures, differing only in
the way their vertice nd edges are labelled or only in the way they are represented geometrically
for any purpose, we regard them as essentially the same graphs.
When G and G‘ are isomorphic we write G G‘
Solution: We note that each of the two graphs has 6 vertices and nine edges. But, the first graph
has 2 vertices of degree 4 where as the second graph has 3 vertices of degree 4. Therefore, there
cannot be anyone-to-one correspondence come between the vertices and between the edges of the
two graphs which preserves the adjacency f vertices. As such, the two graphs are not isomorphic.
The problem was to begin at any of the four land areas, walk across each bridge exactly
once and return to the starting point one can easily try to solve this problem empirically but
all attempts must be unsuccessful, for the tremendous contribution of Euler in this case was
negative.
In proving that the problem is unsolvable, Euler replaced each land area by a point and each
bridge by a line joining the corresponding points these by producing a ―graph‖ this graph
is sho n in fig(1.2) where the points are labeled to correspond to the four land areas of
fig(1.1) showing that the problem is unsolvable is equivalent to showing that the graph of
fig(1.2) cannot be traversed in a certain way.
In proving that the problem is unsolvable, Euler replaced each land area by a point and
each bridge by a line joining the corresponding points these by producing a ―graph‖ this
graph is shown in fig(1.2) where the points are labeled to correspond to the four land areas
of fig(1.1) showing that the problem is unsolvable is equivalent to showing that the graph
of fig(1.2) cannot be traversed in a certain way.
Trees
• Connected graph without circuits is called a tree. Graph is called a forest when it does not
have circuits. A vertex of degree 1 is called a terminal vertex or a leaf, the other vertices
are called internal nodes. Examples: Decision tree, Syntactic derivation tree.
• Any tree with more than one vertex has at least one vertex of degree 1. Any tree with n
vertices has n – 1 edges. If a connected graph with n vertices has n – 1 edges, then it is a
tree
Rooted Trees
• Rooted tree is a tree in which one vertex is distinguished and called a root. Level of a vertex
is the number of edges between the vertex and the root. The height of a rooted tree is the
maximum level of any vertex. Children, siblings and parent vertices in a rooted tree.
Ancestor, descendant relationship between vertices
• Binary tree is a rooted tree where each internal vertex has at most two children: left and
right. Left and right sub trees.
Spanning Trees
• A sub graph T of a graph G is called a spanning tree when T is a tree and contains all
vertices of G. Every connected graph has a spanning tree. Any two spanning trees have the
same number of edges. A weighted graph is a graph in which each edge has an associated
real number weight. A minimal spanning tree (MST) is a spanning tree with the least total
weight of its edges.
Directed Trees
A directed tree is a digraph whose underlying graph is a tree and which has no loops and no
pairs of vertices joined in both directions. These last two conditions mean that if we interpret a
directed tree as a relation, it is irreflexive and asymmetric. Here is an example.
Theorem: A tree T(V,E) with finite vertex set and at least one edge has at least two leaves (a
leaf is a vertex with degree one). Proof: Fix a vertex a that is the endpoint of some edge. Move
from a to the adjacent vertex along the edge. If that vertex has no adjacent vertices then it has
degree one, so stop. If not, move along another edge to another vertex. Continue building a path
in this fashion until you reach a vertex with no adjacent vertices besides the one you just came
from. This is sure to happen because V is finite and you never use the same vertex twice in the
path (since T is a tree). This produces one leaf. Now return to a. If it is a leaf, then you are done.
If not, move along a different edge than the one at the first step above. Continue extending the
path in that direction until you reach a leaf (which is sure to happen by the argument above).
Rooted Trees
Sometimes it is useful to distinguish one vertex of a tree and call it the root of the tree. For
instance we might, for whatever reasons, take the tree above and declare the red vertex to be its
root. In that case we often redraw the tree to let it all ―hang down‖ from the root (or invert this
picture so that it all ―grows up‖ from the root, which suits the metaphor better)
It is sometimes useful to turn a rooted tree into a rooted directed tree T′ by directing every
edge away from the root.
Rooted trees and their derived rooted directed trees have some useful terminology, much of
which is suggested by family trees. The level of a vertex is the length of the path from it to the
root. The height of the tree is the length of the longest path from a leaf to the root. If there is a
directed edge in T′ from a to b, then a is the parent of b and b is a child of a. If there are directed
edges in T′ from a to b and c, then b and c are siblings. If there is a directed path from a to b,
then a is an ancestor of b and b is a descendant of a.
Theorem: If G(V,E) is a connected graph with n vertices and n–1 edges is a tree.
Proof: Suppose G is as in the statement of the theorem, and suppose G has a cycle. Then we
can remove an edge from the cycle without disconnecting G (see the next slide for why). If this
makes G a tree, then stop. If not, there is still a cycle, so we can remove another edge without
disconnecting G. Continue the process until the remaining graph is a tree. It still has n vertices,
so it has n–1 edges by a prior theorem. This is a contradiction since G had n–1 vertices to start
with. Therefore G has no cycle and is thus a tree.
(Why can we remove an edge from a cycle without disconnecting the graph? Let a and b be
vertices. There is a simple path from a to b. If the path involves no edges in the cycle, then the
path from a to be is unchanged. If it involves edges in the cycle, let x and y be the first and last
vertices in the cycle that are part of the path from a to b. So there is a path from a to x and a
path from y to b. Since x and y are part of a cycle, there are at least simple two paths from x to
y. If we remove an edge from the cycle, at least one of the paths still remains. Thus there is still
a simple path from a to b.)
number of parts. Then the decoded version of the sequence is written down.
Splitting: 10 0 111 1101, Decode: e b a d
Splitting: 10 111 10 0 1100 0 1101, Decode: e a e b c b d
Splitting: 1101 111 1100 10, Decode: d a c e
2. Obtain the prefix code represented by the following labeled complete binary tree.
Leaf : a b c d e
Sequence: 000 001 01 10 11
Assignment Questions
1) Explain the types of graphs.
2) What is optimal tree? Explain the Huffman code procedure.
Outcomes
After completing this module one can
Understand the concept of graphs and trees.
Solve problem involving graphs and trees.
3. Kenneth H. Rosen: Discrete Mathematics and its Applications, 6th Edition, McGraw Hill
2007.
5. D.S. Malik and M.K. Sen: Discrete Mathematical Structures: Theory and Applications,
Thomson, 2004.
6. Thomas Koshy: Discrete Mathematics with Applications, Elsevier, 2005, Reprint 2008.
7. https://en.wikipedia.org/wiki/Rule_of_product
8. https://en.wikipedia.org/wiki/Hasse_diagram
9. https://math.feld.cvut.cz/habala/teaching/dma-e/book4x.pdf