0% found this document useful (0 votes)
493 views118 pages

Insights On Discrete Structure

Uploaded by

suraj poudel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
493 views118 pages

Insights On Discrete Structure

Uploaded by

suraj poudel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 118

~- \

iI
-
l ~
,.
l ~

-
-, f

',. __~-
,; ~:
J -.
·:''

i.
CONTENTS
3.3 Solution of Nonlinear Recurrence Relations .............. .. .............. J2 I
Ch,1ptt1r - 1 3.4 Application to Algorithm Analysis ....... ................................ ...... 127
LOGIC, INDUCTION AND REASONING
SOLVED NUMERICALS ....................................................... 130
1.1 . . ...............•·· ••· •··· ·· .. · · ·· ··· ································· I
Discrete Mathemaucs
Ch,1ph•r - 4
1.2 Logic, Induction and Reasoning •··••·•············ .. ··········· .... ··············· .. 3
GRAPH THEORY
1.3 Proposition and Truth Function ...... •.. ••··••········· .. ···· ... ·· ... · .... ·· .. · .. · .. · 6
4.1 Graph .............................................. ............................................ 136
1.4 Propositional Logic ............................... ."................ .... :........ ........... 7
4.2 Undirected and Directed Graphs .... ............................................ 138
1.5 Expressing Statements in Propositional logic ..... ........................ 16
4.3 Graphical Tenns and Terminologies .......................................... 139
1.6 The Predicate Logic ........................................... :.................... :..... 17
4.4 Bipartite Graphs, Planar Graphs, Regular Graphs ...................... 153
1.7 Arguments, Argument Forms and V~lidity .................. ::.............. 24
4.5 Walk Paths, Circuits, Components ............................................. 160
1.8 Rules of Inference ....... _...........................: .................: .... : ............. 25
4.6 Connectedness Algorithm........................................................... 162
1.9 ronnal and lnfonnal Proof.................................... , ...................... 28
4.7 Cut Sets and Cut Vertices ........................................................... 163
1.10 Informal Deduction in Predicate Logic .............. •·: •···· ·· .......... •····· 33
4.8 Eulerian Graph ............................................................................ 165
1.1 l lnfonnal Proofs and Fonnal Proofs .....................................,........ 36
4.9 Hamiltonian Graph ..................................................................... 167
1.12 Elementary Induction and Complete Induction ................ ............ 4 7
4.10 A shortest Path Algorithm .......................................................... 168
1.13 Consistency and Completeness of the System .............................. 55
4.11 Tree as a Directed Graph ............................................................ 175
1.14 Method of Tableaux. ........ - ........................................................... 55
4.12 Binary Search Tree .............................................................. ....... 181
SOLVED NUMERICALS - · - - · - - · · -..........- ........ 63
4.13 Prefix Codes ............................................................................... 183
<haplN- 2 4.14 Spanning Tree............................................................................. 186
FINITE STATE AUTOMATA 4.15 Graph Coloring ........................................................................... 198
2.1 Sequential Circuits and Finite state Machine ............................... 73 4.16 Max Flow and Min Cut .............................................................. 200
2.2 Finite state AutoDJata......- ............................................................ 76 SOLVED NUMERICALS ----·-··--······--··--····--···-·············· 204
2.3 Language and Grauunar ······················································:·....... 80
2.4 Language and Automata ............................................................... 86
2.5 Non-deterministic Finite State Automata ..................................... 89
2.6 Regular Expression and its Characteristics ................................... 93
SOLVED NUMERICALS - ··-··-·········.......................... 101

<haptN - ·3
RECURRENCE RELATION
3. 1 · Defi
Recursive . · · o f ---t'"-Dces
mt1on ~.. .. .......................................... . 110

3.2 Solution of Linear Recurrence Relations .................................... l 12


tlihhit!Hi
Logic, Induction, and Reasoning
1.1 Discrete Mathematics
Di crete mathematics i one of the branches of mathematics
that deal ' with di crete objects and structures. Discrete objects are
distinct object ( eparated or not connected or opposite of
continuous objects) with eparate value such as tree, people, house,
etc. Discrete strurture is the abstract mathematical structure used to
represent discrete objects and relationshjps between the objects
e.g., set, relations, graphs, trees, and finite state machines. Discrete
structures are structures that are used in describing discrete
mathematics.
Discrete mathematics is finite mathematics contrast to
continuous mathematics. In finite mathematics the values are
separate (integer) whereas in continuous mathematics values are in
range (real number). The objects are continuous and vary smoothly
in continuous mathematics, e.g., in calculus.
Discrete mathematics is the mathematical language of

Jr
. -]'
.
.
computer science as information is stored and manipulated in a
discrete form by computing machines. It is mathematics of integers
and collection of objects that triggers the operation of digital
computer. Discrete mathematics is widely used in all fields of
computer science for programming and reasoning about data
structures, algorithms and comple, ity. It enables to formulate
problems. precisely. solve the problems. apply formal proof
techniques, and explain their reasoning clearly. Discrete
mathematics deals with the questions like:
• In how many , ays the valid password can be chosen?
• What is the probability of winning a lottery?
• How can a list of integers be sorted in increasing order?
• How the shortt!st path between two cities can be
determined?

lnsl1hts on Discrete·Structure I1
r \
Uses of Discrete Math in Computer Science
2. Relational thinking (graph theory sets fu .
Discrete mathematics is widely used in various field of . ) , , nctions, database
re lahons
computer science like in Networking, Database, Image Processing,
Programming Languages, Compilers & Interpreters, Software 3. Recursive thinking (recurrence relati·ons, recursive
.
. data
Engineering, Artificial Intelligence, Computer Architecture, structures (bmary search trees))
4. Quantitative thinki~g
Operating Systems, Security & Cryptography, Advanced . h . . (counting, combinations, p'e. rmutat·10ns,
Algorithms & Data Structures, and Graphics & Animation. pigeon ole, big-Oh notation) ,.
5. Analytic~I thinki~g (apply previous tools, algorithm
Reason Behind Studying Discrete Mathematics:
complexity, analysis of algorithms)
There are two reasons behind studying discrete mathematics: 6. Applied thinking (problem solving skills, modeling)
i. To develop mathematical maturity
_ piscrete Mathematics is essential to Computer Science. The
ii. To enter to more advanced mathematical sciences
vanou~ aspects of discrete mathematics form the foundation for
i. To develop mathematical maturity: mod~lmg comp~ting structures, designing programs and
The study of discrete mathematics is necessary to upgrade algonthms, reasoning
. about programs and algorithms, solvmg· rea-l
the ability to understand and create mathematical arguments. ~o~ld probl~ms usmg the computer in particular, solving problems
This skill is important to get very far in the studies m m mfo~at~on ~echnology i.e., problems involving computers,
mathematical sciences. commumcatton, mformation.

~
ii. To enter to more advanced mathematical sciences 1.2 . Logic, Induction and Reasoning
Discrete mathematics is the gateway to more advanced 1.21 Logic
courses in all parts of mathematical sciences. Discrete

!~
j.
mathematics provides mathematical foundations for many
computer science courses incl~ding data structure
algorithms, database theory, automata theory, formal
Logic is a particular -.,,ay of thinking, especially one that is
reasonable and bas_ed on good judgment. More precisely, logic is
the study ~f reaso~mg or method of reasoning. Logic is a language
:;r r~omng. _It 1~ ~ co!lection of rules that is used in logical
r
i
language, compiler theory,. computer security, operating,
systems, math courses based on the material studied in . asomng. Logic d1stmgwshes valid and invalid arguments. Logic
IS
discrete ~thematics including logic, set theory, number
theory, liner algebra, abstract algebra, combinatorics, graph · • Crucial for Itlathematical reasoning
theory, probability theory. Discrete math contains necessary • Important for program d~sign
mathematical background for solving problems in operations • Used for designing electronic circuitry
research, chemistry, engineering, biology. Discrete
l.2.1:1 Types of logic
mathematics develops mathematical reasoning and problem
solving. ' 1. Propositional logic (logic of sentences)
Propositional logic is the study of propositions where ·a
Aspects of Discrete Mathematics:
proposition is a statement that is either true' or false.
I. Logical thinking (propositional, predicate logic, proof
Propositional logic may be used to encode simple arguments
method, prolog) that are.expr~ssed in natural language, and to determine their

Insights on Discrete Structure I 3


2 t Insights on Discrete Structure
validity. The validity of an argument may be dete~ined
specific, logical conclusion. Deductive reasoning usually follows
from truth tables, or using inference rules to establish the steps. First, there is a premise, then a second premise, and finally
conclusion via deductive steps. an inference. For example, the premise ''. Every A is B" could be
2. Predicate logic (logic of objects) followed by another premise, "This C is A." Those statements
Predic:lte logic can represent quantity that allows complex would lead to the conclusion "Thjs C is B." Syllogisms are
facts about the world to be represented, and new facts may considered a good way to test deductive reasoning to make sure the
be detennined via deductive reasoning. Predicate calculus argument is valid.
includes predicates, variables and quantifiers, . and a For example, "All men are mortal. Hari is a man. Therefore,
predicate is a characteristic or property that_the s~bJect of a Hari is mortal." For deductive reasoning to be sound, the
statement can have. The universal quantifier 1s used to hypothesis must be correct. It is assumed that the premises, "All
express a statement such as that all members of the domain men are mortal" and "Hari is a man" are -true. Therefore, the
of discourse have property P, and the existential quantifier conclusion is logical and true. In deductive reasoning, if something.
states that there is at least one value of x has property P. is true of a class of thjngs in general, it is also true for all members
of that class.
1.2.2 Induction
Inductive reasoning
Deduction is to find the value from known to known. E.g,
Man is mortal. Ram is a man. So, Ram is mortal. It is top to Inductive reasoning is the opposite of deductive reasoning.
Inductive reasoning makes broad generalizations from specific
bottom, general to specific approach. It is guaranteed.
observations. Basically, there is data, then conclusions are drawn
Induction is to find the value from known to unknown. It is from the data. In inductive inference, we go from the specific to the
bottom to top, specific to general approach. E.g., "The coin I pulled general. We make many observations, discern a pattern, make a
from the bag is a penny. That coin is ~penny. A third coin from the generalization, and infer an explanation or a theory. An example of
bag is a penny. Therefore, all the coins in th~ bag ar~ pennies." inductive logic is, "The coin I pulled from the bag is a penny. That
Induction is the act of bringing forward something (such as coin is a penny. A third coin from the bag is a penny. Therefore, all
facts or particulars). More Precisely induction is the act of causing the coins in the bag are pennies."
or bringing on or about. . !nductive reasoning has its place in the scientific method.
Sc1ent~sts use it to form hypotheses and theories. Deductive
1.2.3 Reasoning reasonmg allows them to apply the theories to specific situations.
Reason is the action of thinking about something in a Iogic_al, ·
Abductive reasoning
sensible way. Logical reasoning is the term for different types of
reasoning like deductive reasoning, inductive reasoning and . ~nother form of scientific reasoning that doesn't fit in ;ith
abductive reasoning. They are based on deduction, induction and mduct1ve or deductive reasoning is abductive. Abductive reasoning
usually_ sta~s with an incomplete set of observations and proceeds
abduction respectively. !0
the hkehest possible explanation for the group of observations It
D.eductive reasoning inti based. on n:iak:i ng and testmg
1s · h ypotheses using the best ·
Deductive reasoning is a basic form of valid reasoning. . ormahon available. It often entails making an educated guess
after o~serving a phenomenon for which there is no clear
Deductive reasoning, or deduction, starts out with a general explanation.
statement, or hypothesis, and examines the possibilities to reach a

i\ I Insights on Discrete Structure


Insights on Discrete Structure IS
\
5. Close the window! (Command)
. to their living room and finds
· l erson walks 10 • 6. What is your mobile number? (Interrogation)
For examp e, a P Th person's dog has been alone 1n
tom up papers all over the floor. el des that the dog tore up the Basicaly, proposition is denoted by variable
The person cone u
the room all d ay. .k ly scenario. Now, the person's p: Today is Sunday
· · the ·most 1I e
Papers because 1t is . . and she may have tom up the q:l+J = 3
b ht by bis mece
sister may have roug · d by the landlord, but the dog
·t y have been one • · fu Atomic Proposition
papers, or 1 ma . Abductive reasoning 1s use I
. th ore likely cone1usion. . . ft A proposition consisting of only single proposition variable
theory 1s e m be d Abductive reasoning 1s o en
fi · hypotheses to tes1e · db or a single propositional constant is called an atomic or primary or
for ormmg d' sis based on test results an y
d who make a 1agno primitive or simply proposition, that can't be further subdivided.
use_d by octors · . . b d on the evidence presented to
jurors who make dec1s1ons ase
Compound propositions:
them. •
A proposition obtained from the combination of two or rriore
1.3 Proposition and Truth Function proposition by means of logical operators or connectives of two or
more proposition or b;y negating the single proposition is referred to
1 3 t Proposition molecular or complete or compound proposition.
• • .. . a declarative sentence that is either true or
Proposition 1s l ·
lse but not both. True value is denoted by T an~ f~se va u~ is
&'; 1.3.2 Truth Value, Truth Table, and Truth Function
ia . . d ed b 1 and O m bit operation.
denoted by F. Sometimes it JS enot Y ._ Truth Value:
Exclamations and commands are not propositions.
The trutbness or falsehood of a proposition is called its truth
Propositions are denoted by a lower case letter, like: p, q, r, value. We denote T for True and F for FaJse.
s, or t. The variables p, q, r, s, or t are Boolean vanable (or
Truth Table:
variables).
Table of all possible combination of variables and their result
The following sentences are propositions that shows the truth values of a proposition is called truth table.
1. Today js Monday. Truth Function
2. Sun rises from the east.
A truth function is a function that accepts truth values as
3. Sun rises from the west.
input and produces a truth value as output. Propositional logic is an
4. Pokhara is the capital of Nepal. example of truth function, wherein a compound statement is
5. 1 + 2 = 3 constructed by one or two statements connected by a logical
6. 1 + 2 > 5 connective. The compound statement is called a truth function, and
7. If xis an integer, then x2 is a positive integer the logical connective is said to be truth functional.

Toe following sentences are not propositions 1.4 Propositional Logic


L x + 3 = 9 (x is unknown)
Propositional logic is a system based on propositions.
2. Let him go! (Exclamation)
Propositional logic, also known as sentential logic and statement
3. Do your work. (Imperative sentence) logic, is the branch of logic that studies ways of joining and/or
4. , Obama was a great president of USA. (Opinion)
Insights on Discrete Structure I7
6 I Insights on Oisaete Structure
s or sentences to fonn Disjunction (v)
.. statement 2.
" " " entire propos1uons, ts or sentences, as we1I as
modi_., ,n5 · · statemen th Let p and q be two propositi~ns. The proposition ' p or q ' is
complicated propositions, . · that are derived from ese
more . h. and properties . denoted by p v q and it is false when both p and q are false
the logical relan~n~ ips ltering statements. otherwise it is true.
methods of combinmg or a
p q pvq
1.4.1 Connecth•es . hich are used to get new T T T
th Ose notations w
Connectives are .f ns The common used F T
.. from sriven propos1 to . T
propos1t1ons ~
tives are as follows: F T T
connec ed b
.
1. ConJuncnon • (AND) denot · Y " F F F
2. Disjunction (OR) denoted by v p : Today is Wednesday
3. Negation (NOT) denoted by -, or - q : It is raining.
4 Implication (if . ..then .. .) denoted by -+ 3. Negation (-,)
· . ·.
5. Double impbcatton
(iif d ly if) denoted by H
an on Let p be a proposition. The statement 'It is not the case p ' is
6. Exclusive denoted by EB the negation of p. It is denoted by -.p.

1.
7_ NOR'( not OR) denoted byJ..
8 _ NAND ( not AND) denoted by :t
CooJ·uoctioo (A)
· · '
Let P and q be two propositions. The proposttton p an
denoted by pAq and is true only when p and q are true.
d q'
.
ts
_I-;~I_TI
p : Today is Monday.
,p : Today is not Monday.
Truth table of pAq ,p : It is not the case that today is Monday.
p q pAq 4. Implication ( - ) (conditional implication)
T T T
Let P and q be two propositions. The conditional statement
T F F
P- q is the proposition ' ifp then q'.
F T F
The proposition p - q is false only when p is true and q is
F F F false otherwise true.
..
Let p is proposition 'I am in college'. q is propos1tton 'It is : p q p ➔ q
cold'. T .
T T
pAq is I am in college and it is cold. T F F
Sometime but is used instead of and. F
E.g., The sun is shining but it is raining.
- F
T T
F T
lfl b

----
ecome HOD, I will give laptop to every student.

8 I Insights on Discrete Structure


- - -- - - - -- -- .l;n~sl~g~ht;:s~o=n~D~f;:s::c,=e:-te=-=st-:-,-u-ct_u_r_e.~,-9- - - -
p: I become HOD. Among these three conditional statement formed from p -
q: l wj.ll give laptop to ev..ery student. . q, only contra positive is logically equivalent to p _. q. (i.e.
In this example, the first part, p:lf l become_HOD, is_ ~ailed as
-,q _. -,p has the same truth value p _. q)
hypothesis or antecedent or premise or sufficient condition. Q Show that implication and its contra positive are logically
. l will give laptop to every student, is equivalent
The seeond. Part, q • ..
called conclusion or consequence or necessary c?nd1hon. p q p-q -,q -,p -,q-.p
The following statements are the ways to express the T T T F F T
implication or conditional statement. T F F T F F
1. If p then q F T T F T T
2. If p, q F F T T T T
3. pis sufficient for q 5. Bi-conditional or bi-implication (H)
4. q ifp Let p and q be two propositions, the bi-conditiona1 statement
5. q when p p H q is the proposition 'p if and only if q!. Thebi-
6. p implies q conditional statement pHq is true when p and q have same
truth values other'Wise false.
7. p only if q
8. a necessary condition for p is q p H q is expressed as
· 9. a sufficient condition for q is p • p if and only ifq
10. q whenever p • piffq
11. q is necessary for p. • p is necessary and sufficient condition for q
12. q follows from p. • if p then q and conversely
13. q unless -,p. (p H q) = (p _. q)A(q _. p)
Converse p q p+-+q
The converse is computed by interchanging the hypothesis , T T T
and conclusion. If we have conditional statement p -+ q then T F F
·,

the converse is q - . p F T F
Inverse F F T
The inverse of conditional statement is the negation of botb.
the hypothesis and the conclusion. If we have condinon
· al Example, you can take the flight if and only if you buy a
ticket.
statement p _. q then the inverse is -,p - -,q 6. Exclusive OR (EB)
Contrapositive
· the Let p and q be propositions, p EB q is true when p is true and
Toe contrapositive is · computed by interchangm~. i
q is false or q is true and p is false. It is false when both p
hypothesis-an4 conclusion of inverse. If we have condition ·
and q are false or both are true.
statement p - q then the inverse is -,q -+ -,p
Insights cm Discrete Structure I 11
10 I Insights on DISQ"ete Structure
------------------., J

Example, Student who have take~ calculus or computer Lo21c andb.1t operation
science b ut not both can enroll in th1 s class. · X y xvy x-y .-,:
XAY x+-+y
p q p<Bq
0 0 0 0 I l
T F 0 I 0 l l 0
T
F T l 0 0 l 0 0
T
T T I l J J I J
F
F F Q. Find bitwise OR, bitwise XOR of bit strings 0110110110
F
and 1100011101. · [Do it yourselj]
7. NOR ( not OR) (J..)
NOR is negation of OR. For two propositions p and q,
1.4.2 Tautology, Contradiction and Contingency
Tautology
p-l.q = -, (pvq)
A compound proposition that is alway~ true no matter what
8. NAND ( not AND)(i)
the truth values of the proposition occur in it, is called tautology.
NANO is negation of AND. For two propositions p and q,
e.g., pv -,,, -,>A(pvq) - q, [(p-q)l\p]-q
piq = -,(pAq)
Contradiction
Precedence of operator
I. -, A compound proposition that is always false no matter what
the truth values of the proposition occur in it, is called
2. /\ contradiction.
3. V
e.g., PA-,>, (pvq)A[( -,>)/\( ~]
4. -
5. H
Contingency
-,>Aq means (-,,)Aq A compound proposition that is neither tautology nor
contradiction is called contingency. ·
pAq-+r means (pAq)-r
Q) Construct the truth table of compound proposition (-pN/) e. g., (pA~ - (pAq), (pvq) I\ ( -,,)

-(pAI/) Logical equivalence(=)(~)


p q ...,, -,,Aq (pAq} (-,,Aq) ....,. (pAq} !wo statements x and y are logically equivalent if any of the
- followmg two condition holds
T T F F T T
i. The truth table of each statement have same values
T F F F F T ii. The biconditional statement xHy is tautology
F T T T F F T_he compound propositions that have same truth values in
F F T F F T all possible cases are called logically equivalent.

Insights on Discrete Structure I 13


12 I Insights on Discrete Structure
Let p and q be propositions. They are logically equivalent if
6. (p V q) V r ¢:::> p V (q. V r) Associative law
pHq is tautology. (p "q)" r ¢:::> p /\ (q /\ r)
Q. Show following proposition are logically equivale11t 7. p V ( q /\ r) ¢:::> (p V q) /\ (p V r) Distributive law
l . -{pvq) and 7'"-,q p" (q v r) ¢:::> (p A q) v (q Ar)
2. p - q and ..,pvq 8. -,(p I\ q) ¢:::> (-,p V -,q) De-morgan's law
3. pv(qAr) and (pvq)A(pvr) -,(p V q) ¢:::> -,p /\ -,q
4. -'(pv(-,,Aq)) and 7'"--.q 9. pv(pAq)<=>p Absorption law
(p - q) ~ (--.pvq) p /\ (p V q) <=> p
,

p-q --,p --.pvq 10. p v-,p <=> T Negation law


p Q
T T F T p A -,p <=> F
T
F F F F Useful logical equivalence
T
T T T T (p -+ q) = (-,pvq)
F
F F T T T
Q) Showthat
pHq -= (p - q)A (q - p) 1. ..,(p v(-pAI/)) ~ (-pA..,q) (to prove is logically equivalent)
p q p+-+q p-q q-p (p-q)A(q-+
2. pAI/)-+ (pvq) is tautology
p)
T T T 3. (p-q} A(p-+r) =JJ-+_(q.N)
T T T
T F F F T F Solutions:
F T F T F F 1. -{p V (7' /\ q))
F F T T T T = --,, I\ '"'"""'P I\ q)
L021C ·atences
"alE1qu1v = """1) /\ (p V ,U
S.N. Equivalence Name = (7' /\ p )v("""'P " 'l)
·1. pAT<=>p Identity law = F V ("""1) /\ 'l)
pvF<=>p = ("""'P /\ --.q) V F
2. pvT<=>T Domination law =(--,,I\ ,v
pAF¢:::>F 2. (p /\ q) -+ (p V q)
3. pvp<=>p Idempotent law =-,(p /\ q) V (p V q)
pAp<=>p =--,,v--qvpvq
4. -,(-,p) <=> p Double negation law = {-,p V p) V (--q V q)
5. pvq<=>qvp Commutative law =TvT
=T
pAq<=>qAp -

14 I Insights on Discrete Structure Insights on Discrete Structure I 15


r ·.l.5
St tements in Propositional Logic
Expressmg _8 •

Translate the sentence in propositional logic


1.6 The Predicate Logic
Predicates and Quantifiers

Q.
h
It sniws w enever +
the wind blows from the northeast A predicate is a declarative sentence whose truthiness or
falsehood depends on one or more variables. Predicate is
Hypothesis propositional function
Conclusion
"x is greater than 4"
Iftbe wind blows from the north-east then it snows
Subject: x
p : The wind blows from the northeast
Predicate: "is greater than 4" (property of statement)
q : It snows
P(x) :"x greater than 4"
p-+ q
where x is the variable and p is the predicate "is greater than
Q. To ,ei tenure as a professor, it is sufficient to be world
4"
ftunOUS.
Assign a value to x and P(x) becomes a proposition.
If you are world famous then you can get tenure as a
professor. P(x) is also called the value of propositional function at x.
p: You are world famous P(x) denotes x>3, what are truth value of p(x) and p(l)
q : You can get tenure as a professor P(4), setting x = 4, 4>3 is True.
p-+q P(l), setting x = 1, 1>3 is False.
Q. Tl,e tlutomated reply cannot be sent when the file system is • Propositional logic is not sufficient to express the meaning of
. j,,IL [conclusion is statement before when] statements in mathematics.
p : The automated reply can be s_ent. • Predicate logic is more powerful type of logic .
q : The file system is full. • Predicates are also used in verification that computer
q-+.,, programs always produces the desired output when given
Q. JlJIM is either smart or honest but Ram is not honest if he is valid input. The statements that describe valid inputs are
JMart. preconditions and the conditions that output should satisfy
P: Ram is smart when the program has run are called post condition.
q: Ram is honest temp= x
x=y
(pvq) A (p-,0
Q. is muut is necessary and suflkient for Ram to be
JlJUI,
y = temp
lwnot. For precondition, we need to express that x and y have
P: Ram is smart particular values before we run the program. For precondition we
q: Ram is honest use the predicate P(x, y) is statement where x = a and y =b . As we
' want to verify that program swaps the values of x and y, fOT post
!
i· . -_ _ J>H<l
_ _ _ _ _ _ _ __
Insights on Discrete Structure I 17
J 1' I lt.Jipa on Discrete Structure
r .
condinon we use
Q(x y) where Q(x y) is statement x =bandy==
, ,
a. To verify, suppose that the precondition we use ~(x, y) statement
· true In 1st ·step temp= x, after this step we know
Examples
Q. Let p(x) be "x2>10", what is the truth value of l:fx P(x)
x=aand y= b 1s . ,
nd
x = a, temp = a and y =b. after 2 step, x = y we know x = b, temp i. The set ofreal number (Ans. F)
\

= a, y = b. Finally after 3rd step, ,ve know th~t-x = b, temp = a and y ii. The set of positive number not exceeding {1, 2, 3, 4}
=a.After this program is run the post cond1t1on Q(x, y) holds, that (Ans. F)
is, the statement "x =bandy= a" is true. = p(l) A p(2) A p(J) A p(4)
=FAFAFAFAT
Quantifiers
=F
Quantifier defines the quant~~ or quantifi~~tion.
Quantification is a way to create a propos1tton from a propos1ttonal iii. Let set of real number in the interval /10,50} (Ans. T)
function. It expresses the extent to which a predicate is true over a Q. Let Q(x) be the statement 'x<2 ', what is the truth value of
range of elements. the quantification l:fx Q(x) where domain consists of all
real numbers.
Two types of quantification
l . Universal quantification Q(x) is not true for every real number x. Q(3) is false, that is
2. Existential qualification Q(3) is a counter example of statement Vx Q(x). Thus Vx
Q(x) is false.
Universal quantification
Existential Qualification
Universal quantification tells us that a predicate is true for
every element under consideration. The universal quantification of Existential quantification tells, us that. there is one or ~ore
P(x) for a particular domain is the proposition that asserts that P(x) element under consideration for which predicate is true.
is true for all values of x in this domain. · Ddmain specifies the _The existential quantification of P(x) is the statement "There
possible values of the variable x. is an element x in the domain such that P(x) is true." It is denoted
The universal quantification of P(x) for all values of x in the by 3xP(x).

domain is denoted by Vx P(x). 3xP(x) is true when P(x) is true for one or more x in the
domain.
VxP(x) is true when P(x) is true for every x.
VxP(x) is false when there is ax for P(x) is false. An element 3xP(x) is false when P(~) is false for all values of x in the
domain.
for which P(x) is false is called a counter example of Vx P(x). If the
domain is empty VxP(x) is true for any propositional function P(x), The element for which P(x) is true is called a witness -0f
since there are no counter example in the domain. 3xP(~). If the ~omain is ~mpty 3xP(x) is false for any propositional
function P(x) smce there 1s not witness in the domain.
When all elements in domain can be listed as xi, X2, X3, . · · '
Xo, the universal quantification VxP(x) is same the conjunction. 3 is called existential quantifier

If the domain is finite {x,, Xz, X3 ..... , Xn}


• Words that express existential quantification are "there
exists", "for at least one", "there is".
VxP(x) is the same as p(x 1) Ap(x 2) ••••• A p(x0 ).

18 I lnsipts on Discrete Structure Insights on Discrete Structure 1·19


If the domain is finite {x l , x2, . ... , xn} or listed as x l.x2 .. ...
• Let Vx(P(x) AVQ(x)) is true. This means that if a is in the
xn, the existential quantification. P(x 1)vp(x2)v . .. .. . p(xn).
domain, P(a) AQ(a) is true. Hence P(a) is true and Q(a) is true.
Examples Because P(a) is true and Q(a) is true fqr every element in the
Q. Let P(x) be "f>lO". what is the truth value of .:/xP(x). domain, we can conclude that VxP(x) and VxQ(x) are both true.
1. The set of real number T This concludes Vxp(x) /\ VxQ(x) is true.
2. The set ofpositive number not exceeding fl, 2, 3, 4} Let \ix p(x) /\ \ix Q(x) is true. VxP(x) is true and VxQ(x) is
= P(.l) v P{2) v P(3) v P(4) true. Hence, if a is in domain, then P(a) is true and Q(a) is true. It
follows that for all a, p(a) AQ(a) is true.
=FvFvFvT
Vx(p(x) /\ Q(x)) = VxP(x) /\ VxQ(x)
=T -
3. The set of real number in the interval /0,✓9. 8/ Negating Quantified Expression
False ((M)2> IO) J. Every student in this class has taken a course in calculus
9.8>10 False VxP(x), let P(x) be the statement "x has taken a course in
Q. P(x) denotes statement "x>3", what is truth value of calculus". And domain consists of the students in this class.
quantification 3/xP(x)? •where domain consists of all real Negation
number? The negation of this statement is "It 'is not the case that every
Because "x>3" is sometime true, for instant when x = 4, the student in this class has taken a course in calculus". This is
. existential quantification of P(x), that is 3xP(x) is true. equivalent to "There is a student in this class who has not
taken a course in calculus". And it is the existential
Q. Q(x) denote statement "x =x + I". Domain consists of real quantification of the negation of the negation of original
number. propositional function. i. e.
Because Q(x) is false for every real number x, the existential ...,\ixP(x)=3x...,P(x)
quantification of Q(x) which is 3xQ(x) is false.
...,VxP(x) is true, if VxP(x) is false.
Binding variables and scope VxP(x) is false, if there is an element x in the domain for
When a quantifier is used on the variable x, we say that this which P(x) is false . ...,P(x) is true.
occurrence of x is said to be bound. ·An occurrence -of a variable Finally there is an element x in the domain for which ...,P(x)
that is not bound by an quantifier or set equal to a particular value is true if and only if3x...,P(~) is true. · ·
is said to be free.
VxP(x) is true if and only if 3x...,P(x) is true.
For example,
2. -.3JxP(x) ~ Vx-iP(x)
3x(x + y = I), variable x is bound by existential "There is a student in this class who has taken. a course in
quantification. calculus." ·
Show that v'x(P(x) " Q(x)) and \fxP(x) "\ix Q(x) are 3xP(x).
logically equivalent (where the same domain is used throughout)

Insights on Discrete Structure I 21


20 I Insights on Discrete Structure
Negation . . Let, p(x) be ' x has studied calculus.'
. h
"It 1s not t e case
that there exist a student m this class
·
Who If we change the domain to consist of all people.
has taken a course in calculus." For every person, if person x is a student in this class, then x
...,3xP(x) has studied calculus .
"£every. student in this class has not taken a course in If Q(x) represent statement the persons is student.

calculus." \ixQ(x) - P(x)


2. Some student in this class bas visited pokbara ,
...,VxP(x)
There is a student that bass visited pokhara
Find the negations Q(x) : student x bas visited pokhara. .
2
1. Vx(x >x)
S(x): xis a student in this class.
2
2. 3x(x == 2)
There is a student x, x is student in the class and x has visited
2
Negation of Vx(x > x) pokbara.
== ...,Vx(x2 > x) 3. Every student in this class has visited either Canada or
2
==3x-. (x > x) mexico
== 3x(x2< == x) \ix(P(x) - Q(x)vR(x))

Negation of 3x(x == 2)
2 4. Every mail message larger than •one megabyte ,will be
compressed.
== ~x(x2== 2) ·
Let x be mail message.
==3x--(x2 == 2)
Let y be megabyte.
== Vx(x2 :f; 2)
Mail message x is larger than one megabyte. i. e.
Resbicting the domain of a quantifier S(x, y)
1. Vx>O (x2>2) ¢:>Vx (x>O - x2>o) Message will be compressed. i. e. C(x)
2. Vy:#) (y3 = 0) is same as Vy (y = O - y 3=,:0) \ix (S(x, y) - C(x))
3. 3z>O (r= 2) is same as3x(z = 0Az2= 2) 5. Consider the statement
Tr~slate into logical equivalence · "alt lions are fierce."
1. Every student in this cla~s has studied calculus. "Some lions do not drink coffee."
Here, P(x) : x is lion.
Domain = aU student. Q(x) : x is fierce
For every student in this class, that student has studied Vx (P(x) - Q(x))
calculus.
3~(P(x)A-. R(x))
Let x be the variable, so that for every student x in this class,
3x(Q(x)A-. R(x))
x has studied calculus.

22 Hnsights on Discrete Structure lnsl1hts on Discrete Structure I 23

~§Ilk.Ji
Nested quantifiers valid if the truth of all its premises implies that the conclusion is
1) 'v'x'v'y (x + y = y + x) . true.
+y- y+x An argument form in propositional logic is a sequence of
For every x and for every Y, x -
compound propositions involving propositional variables. An
2) Vx3y(x + y = 0)
argument form is valid if no matter which propositions are
For all real no. x, there is a real no. y such that x + y = 0
substituted for th~ propositional variables in its premises, if the .
Let Q(x, y) denote (x + y = O). What is truth values of premises are all true, then the conclusion is true.
3)
- t· n3y\/xQ(x y) and \/x3yQ(x, y). where domain
quant1 61ca 10 ,
In other words, an argument form with premises p 1, p 2 , • •• ,
consist of all real number.
Pn and conclusion q is valid if and only if (p 1A p2A · · · A p 0 ) - q
3y\/x Q(x, y) is False is a tautology.
\/x3yQ(x, y) is True Validity is the quality of being logically or factually sound;
why? soundness or cogency. It is the state of being acceptable.
3 \/xQ{x, y) means that "There is a number y such that for
1.8 Rules of Inference
y
every real number x, Q(x + y = 0). II w h'
.1ch 1s
. 1a
"'Ise.
Rules of Inference
\/x3yQ(x, y) means that_"For all rea~ no. _x, ~ere is a real no.
y such that Q(x y) that 1s x + y = 0. which 1s true.
1
An argument is a sequence of statement that ends with a
' ' conclusion. The argument is valid if the conclusion (final
Statement When True? When False?
statement) follows from the truth of the preceding statement
For every pair (x, y), There exists a pair. x, y (premises). Rules of inferences are templates for buil~ng valid
\/x\/yP(x, y) ,
P(x; y) is true. such that p(x, y) is false. arguments. These will be the main ingredient needed in formal
\/y'v'xP(x, y)
proofs.
'v'x3yP(x, y) For every values of x, There exists a x sub that
Example:
there ·is a y such that for for every y, P(x, y) is
P(x, y) is true. false 'If you have a current password, then you can log onto the
network. '
8
.3xv'yP(x, y) There exists a x such For every x there exists
Let p represents "you have a current password."
that P(x, y) for every y, y such that P(x, y) is false.
q represents "you can log onto the network."
3x3yP(x, y) For some pair (x, y), For all pairs {x, y), P(x, y) - p ➔ q
P(x, y) is true. is false. p
3y3xP(J.C, y) ~

q
1.7 · Arguments, Argument Forms and Validity ___.. ((p- q)Ap) - q is tautology.
Definition:
An argument in ·propositional logic is sequence . of
propositions. All but not the final proposition are called premlS~
and the final .proposition is called the conclusicm. An a r ~
Insights on Discrete Structure I 25
24 I Insights o~ Discrete Stru(ture
Premises
S.N. Rules of Tautology Name
Arguments
inference

' 4. pvq
~
q
[(pvq)A -.,] ...:.+ q Disjunctive
syJlogism

Conclusion , 5. . f p-+ (pvq) Addition


pvq
6. 1!69 {pAq)-+ p Simplification
When both p-+ q and pare true, q must be true: We say this
p
form of argument is valid because whenever all premises are true,
7. p [{p)A(q}] -+ {pAq) Conjunction
the conclusion must also be true.
g
An argument form in prepositional lo_g!c is a s_equence of pAQ
compound preJ>?sitidns involving prepos1t1on vanabl~s. ~ 8. pvq [(pvq)A(7)vr)] -+ (qvr) Resolution
argument formed with premises pl , p2, . ... , pn and conclusion q 1s
.:J2Yr
valid iff (p 1Ap2A ....pn) -+ qis-tautologies. qvr
p Q p-+q {p-+ q)Ap ((p-+ q)Ap)
-+q Which rule of inference is used?
T T T T T Q. It is below freezing and raining now. Therefore it is either
below freezing or raining now.
T F F F T
Let p be proposition "It is below freezing now" and q be
F T T F T proposition "it is raining now."
F F T F T ~
Hence the argument is valid. pvq
S.N. Rules of Tautology Name This is an argument that uses additive rule.
inference Q. If it rains today, then we will not have barbecue today. ff
l. p {pA(p-+ q))-+ q Modus we do not have barbecue today, then we will have a
~ ponens(mode b~rbecue tomo"ow. Therefon, if it r.,ains today, then we
q that affirms) will have a barbecue tomo"ow.
2. ---iq (---iqA{p -+ q)) -+ 7) Modus tollens Let p be proposition "it rains today."
~ mode that denies) Q be proposition "we will not have barbecue today. 11
-p r be proposition "we will have barbecue tomorrow·.11
-
3. p-+q [{p-+ q}A(Q-+ r)] -+ {p Hypothetical p - q
q-+ r -+ r) . syllogism ~ -+ r

p-+ r r
-- p-+

This argument is hypotheticai syllogism.

26 I Insights on-Discrete Structure Insights on Discrete Structure I


27
1.9 Formal and Informal Proof iii.,. - s
1.9.1 Formal Proof iv. s - t
A fomial proof of a conclusion q with given hypotheses p 1, Conclusion
is a sequence of steps, each of which applies some Reasons
P2,PJ·· ·• Pn . S. N. Steps
inference rule to hypotheses or previously proven statements
l. ---pAq Hypothesis
(antecedents) to yield a new true statement (the consequent).
2. --,, Simplification using (I)
A formal proof demonstrates that if the premises are true,
3. r-p Hypothesis
then the conclusion is true. A formal proof is based simply on
symbol manipulation (no need of thinking, just apply rules). A
4. ,. Modus tollens using (2) and (3)
5. .,._ s Hypothesis
formal proof is rigorous but so can be a proof that does not rely on
symbols! Formal proof example (rules of inference to build 6. s Modus ponens using (4) and (5)
arguments) 7. s-t Hypothesis
8. T Modus ponens using (6) and (7)
1.9.2 Informal Proof
The steps of the informal iproofs are not expressed in any Q. "I/you send me an email message then I will.finish writing
formal language as e.g. propositional logic. Steps are argued less the program", "if you do not send me an email message
formally using English, mathematical formulas and so on. One then I will go to sleep early" and "If I go to sleep early
must always watch the consistency of the argument made; logic then I will wake up feeling refreshed" lead to the
and its rules can often help us to decide the soundness of the· conclusion " If I do not finish writing the program then I
argument if it is in question. We use informal proofs to illustrate -will wake up feeling refreshed. "
different methods of proving theorems. Propositions :
Q. Show that the hypothesis "It is not sunny this afternoon p : you send me an email message.
and it is colder than yesterday." "We will go swimming q : I will finish writing the program.
only ifit is sunny." "I/we do not go swimming then we will
r : I will go to sleep early.
take a canoe trip," and "I/we take canoe trip, then we will
be home by sunset " Lead to the conclusion "we will be s : I will wake up feeling refreshed.
home by sunset " Hypothesis :
Let p be the proposition "It is sunny this afternoon." P - q, --,, - r, r - s
q denotes "It is colder than yesterday." Conclusion :
--ci-s
r denotes "we will go swimming."
S. N. Step Reason •
s denotes "we will take canoe trip."
l. P-q Hypothesis
t denotes "we will be home by sunset."
2. --<I - --,, Contrapositive of ( 1)
Then, hypothesis
1. 7)1\q 3. --,,-r Hypothesis
ii. r--+ p

28 I Insights on D!Krete Structure lnslsf1tson Discrete Structure I 29


Reason C2: ...,PvQ (hypothesis)
S. N. Step
. h othetical syllogism of (2) and (3) C3: -,Q (negation of conclusion)
4. -sq-r Usmg YP C4: Q (Cl and C2 resolution)
r-s Hypothesis C5: l'
5.
6. -,q- s Hypothetical syllogism Steps for resolution
1. Change implies ( --+ ) to disjunction(\/)
1.9.3 Resolution Principle 2. · Negate the conclusion
. that an argument is correct, is
• Another way of provmg 3. Use rules
resolution principle._ . 4. If empty clause l' comes, it is proved.
· . fa variable is called literal.
• The variable or negation o A deduction of l' (empty clause) is called refutation of proof
• Clause is a disjunction of literals. . . of a set of clause.
d C2 if there is a literal L1 m Cl Example
. For any two clauses Cl an • d Li
. to a literal L2 in C 1, then delete L1 an
that 1s· complementary . and construct the disjunction of the II argument correct? Prove by resolution principle.
from Cl and C2 respective1y Q, If today is Tuesday, I have a test in mathematics or
remaining clauses suppose. economics. If my economics professor _Js sick, I will not
Cl=PVQVR have a test in economic. Today Js Tuesday and my
economics professor is sick. Therefore, I have a test in
C2=PV-,SVT mathematics.
Then p and -,pis complementary to each ~~r, th~ resolvent T denotes "Today is Tuesday."
of Cl and C2 respectively, and _finding the _d1sJunct1on of the M denotes "I have a test in mathematics."
remaining literals. In this case it is QVRV-,SVT E denotes "I have a test in economics."
E.g., Consider modus ponens S denotes "My economic professor is sick."
p Premises are
T--+ (MVE)
P-0 S--+_,E
Q
TAS
Now, from resolution principle,
conclusion'
Cl: P M
C2: _,PvQ- Solution putting in clause form
Clause Reason
0: ~ b
From Cl and C2 by resolution you can get Q and from CJ Y Cl : .....Tv(MvE) Hypothesis
resolution i is arrived. So, it is valid. C2 : --.sv--.E Hypothesis
It can be written as follows: C3:T Using Simplification in T AS
C1: P (hypothesis)
lnsl1hts on Discrete Structure I 31
90 I lnslat,ts.on Dlacrtte Structure .:J~~;\". ,'

. Simplification in T AS
U smg , . Different connectives are used in universal quantifier
C4:S
Negation of Conclusion and existential quantifier.
CS :--M i. Use implies ( - ) for universal quantifier
From Cl and C2
C6: --TvMv--S ii Use conjunction (A) for existential quantifier
From C3 and C6
C7: Mv--S (Q) For every person x, if a person xis student on this class
From C4 and C7 then x has studied Discrete Structure.
cs:M
From CS and CS S(x): "x is a student in this class."
C9:i
Hence argument is correct. D(x): "x has studied discrete structure."
Vx(S(x) - D(x))
1.9.4 Fallacy . lf ng from incorrect argument. (Q) Some student in this class has visited Mexi.co.
Fallacy is misconception resu l
S(x): "xis a student in this class."
ming the conclusion based on
Fallacy of a{fir M(x): "x has visited Mexico."
-+ p which is NOT a tautology
((p-+ q)/\q) 3x(S(x)/\M(x))
ls the following argument valid? . .
. this book then you wUl learn 1.10 Informal Deduction in Predicate Logic
Q. If you do every pr~blemy; ,n learned discrete mathematics. The informal deduction of a square implies that it has . four
discrete mathemattcs. ou , . . b le.
·" did every problem ,n this oo congruent sides and four congruent angles and with the properties
ThereJore, you . ta· tautology because it)s false when p of a square such as opposite sides parallel and the diagonals
((p-+ q)Aq)-+ p IS no perpendicular bisectors. The following rules of inference are
is false and q is true. informal deduction in predicate logic.
Premises (p -+ q) an~ q Rules of inference for Quantified statement
Conclusion q. f ftirming S. N. Rules of inferenee Name
This type of incorrect reasoning called fallacy o a - I 1. Vxp(x) Universal instantiation
the conclusion. p(c)
2. p(c) Univergal generalization
Fallacy of denying the hypothesis
\Ix p(x)
Based on . 3. 3xp(x) Existential instantiation -
((p -+ q)" --p)-+ -,q which is not tautology. .
p(c)
. thi bo k, then you will learn
If you do every problem m . s ? . k Therefore, 4. p(c) Existential generalization
D.S. you did not do every problem m this boo . 3xp(x)
you didn't learn D.S. •
Show that the premises
1.9.5 Translation of sentences in pr_edicat~,log1c
"Every student in this class has studied D.S..
• A student in section A has taken the course has not read the
book.
For every student x in this class, x has studied D.S. • Everyone in section A has taken the course passed the first
D(x): "x has studied D.S." exam.

V.xD(x) _-/ Insights on Di$Crete Structure I 33

32 I Insights on Discrete Structure


\
I l .. the conclusion I
S.N. Step Reason
mp Y the first exam has not read the book.
Someone who passed " l. Vx(P(x) -+ C(x)) Premise
. h0 has taken the course
A(x) :"xis in section w \ 2. P(marla) -+ C(marla) Universal instantiation
B(x) : "x read the book" 3. D(marla) Premise
ti
P(x) : "x passed the first exam.
4. C(marla) Modus ponens from (2) and (3)
Hypothesis
Q. ;,A student in this class has not read the book" and
3x(A(x)A·.,B(x)), 'v'x(A(x) -+ P(x}) "Everyone in this class passed the first exam" implies that
conclusion "someone who passed the first exam has not
Conclusion:
read the book. "
3x (P{X )/\....,B(X)) Propositions :
Step Reason
S. N. C(x) :xis student in this lass.
1. 3x(A(x)A....,B(x)) Hypothesis R(x) : x has read the book
2. A(a)A....,B(a) Existential instantiation from ( 1) P(x): x has passed the exam.
. Simplification from (2) Hypothesis :
3. A(a)
3x(C(X)/\-.R(x)), Vx(C(x) -+ P(x)
4. 'v'x(A(x) -+ P(x)) Hypothesis
-. Conclusion :
5. A(a)-+ P(a) Universal instantiation from (4)
3x(P(x)/\....,R(x))
6. P(a) Modus ponens from (3) and (5) S. N. Step Reason
7. -.B(a) Simplification from (2) 1. 3x(C(x)A....,R(x)) HYP<;>thesis
8. P(a)AB(a) Conjuction from (6) and (7) 2. (C(a)A ....,R(a)) Using existential instantiation in ( 1)
9. 3x(~))A....,B(x)) Existential generali7.ation from (~ 3. Vx(C(x) - P{x)) Hypothesis
Q. Show that premises "everyone in his discrete mathematics 4. C(a)-+ P(a) Using universal instantiation on (3)
class has taken a course in computer sdence. "And "Marlo
5. C(a) Using simplification on (2)
is a student in this class" imply the conclusion "Marla hos
taken a course in computer science. " 6. P(a) Using modus ponens on (4) and (5)
Let D(x) denote "xis the discrete mathematics class, and let 7. -.R(a) Using simplification on (2)
C(x) denote "x bas taken a course in computer science.~
8. P(a)A-.R(a) Using conjunction on (6) and (7)
Then the premises are· 'v'x(D(x) --+ C(x)) and D(Marla). The
conclusion is C(Marla). 9. 3x(P(x)A-.R(x) Using existential generation on (8)
'

Insights on l!>iscrete-Sttucture I 35
34 f Insights on Discrete Structure
Q. Lions are dangerous animals. There are lions. Therefore
there are dangerous animals. formal proof is rigorous but so can be a proof that does not rely 0 0
L(x) : x is lion. symbols! Formal proof example (rules of inference to build
arguments)
D(x) : x is dangerous animals.
Hypothesis : 1.11.1 Proof Methods
Vx (L(x) -+ D(x)), 3xL(x) A proof is a valid argument that establishes the truth of a
mathematical statement, using the hypotheses of the theorem, if
Conclusion:
any, axioms assumed to be true, and previously proven theorems.
3x.D(x)
Using these ingredients and rules of inference, the proof
S. N. Steps Reasons establishes the truth of the statement being proved.
I. Vx(L(x) -+ D(x)) Hypothesis We move from formal proofs, as seen in the previous
2. L(a)-+ D(a) Universal instantiation on (1) section, to informal proofs, where more than one inference rule
may be used at each step, where steps may be skipped, and where
3. 3x(L(x)) Hypothesis axioms and rules of inference used are-not explicitly stated.
4. L(a) Existential inst~ntiation on (3) Some Terminology
5. D(a) Modus ponens on (3) and (4)
• Definition : A precise and unambiguous description of the
6. 3xD(x) Existential generalization on (5) meaning of mathematical term.
• Theorem: A statement that can be shown to be true using
1.11 Informal Proofs and Formal Proofs vigorous (strong) mathematical reasoning.

I The steps _of the informal proofs are not expressed in any
formal language as e.g. propositional logic. Steps are argued less
formally using English, mathematical formulas and so on. One
A statement that can be shown to be true (sometimes referred
to as facts or results).
Less important theorems are often called propositions.
must always watch the consistency of the argument made; logic • Lemma : A lemma is a less important theorem, used as an
and its rules can often help us to decide the soundness of the. auxiliary result to prove a more important theorem.
argument if it is in question. We use informal proofs to illustrate It is used as an auxiliary result to prove a theorem. It is
different methods ofproving theorems. stepping stone to prove theorem.

A formal proof of a conclusion q with given hypotheses pi, • Corollary: It is a theorem proven as. an easy consequence of
a theorem.
P2, p3 . . . ; Pn is a sequence of steps, each of which applies some
inference rule to hypotheses or previously proven statements • Conjecture : A conjectw:e is a statement that has been
(antecedents) to yield a new true statement (the consequent). proposed a true statement. If proved later then it can be used
as a theorem but it may be false
A formal proof. demonstrates that if the premises are tr11e,
then the conclusio~ is true. A formal proof is based simply on
symbol manipulation (no need of thinking, just apply rules). A

--36 I Insights on Discrete Structure Insights. on DiscreteStructure I 37


Axiom (or postulates) are statements that ~e assume to be
• true v A proof is a valid argument that estabhshes the truth of · 1.11.2 Direct proof ,
a theorem. Assume P is true and the last step establishes q is true.
Rules of inference, Axiom (or postulates): Axiom or Before we give examp Ie of d'1rect proof, we need a
• postulates are statements that we assume to be true (algebraic definition.
axioms specify rules for arithmetic like commutative laws)
Definition
without proof. These are building blocks to prove theorem.
Th~ integ~r n is even if there exits an integer k such that n =
Proof : A proof is a valid argument that establishes the truth
•• · of a theorem. The statements used in a proof include axioms,
2k and n is odd if there exits an integer to such that n = 2k + 1.

,.hypotheses (or premises), previously proven theorems and Theorem (use direct proof)
definitions. Rules of inferences, together with definition of l. If n is an odd integer, then 0 2 Is odd.
t~rms are used to draw conclusions from other assertions Let p(n) : 'n is an odd integer • is true
'
tying together the steps of a proof.
'
then,
Three methods of showing statements of the type p -. q are n = 2k + I (from definition)
true: then,
1. Direct proofs: Assume p is true; the last step establishes q is n2 = (2k + 1)2
true. If n2 = 4k2+ 4k ~ I
2. Proof by Contraposition: Uses a direct proof of the 2
n ~ 2(2k2 + 2k) + J
contrapositive of p - q, which is -iq - . -,,. That is, assume 2
here, (2k + 2k) is an integer, so,
-iq is true; the last step established -,, is true.
2(-2k2 + 2k) is even
3. Proof by Contradiction: To prove that P is true, we assume .
n2 is odd.
-,p is true and reach a contradiction, that is (r A ,-) is true for
some proposition r. In particular, to prove (p -. q), we Definition
assume (p -. q) is false, and get as a consequence a Anb2integer is a perfect square I·f the is
= . an integer
· b such that a
contradiction. Assuming that (p -. q) is false = (-,, v q) is
false= (p.A'""'<l) is true. Theorem
4. Formal and Informal Proof 2. If m and n are both erfect
perfect square. p square the mn is also a
A fonnal direct proof of a conditional statement p ~ q
works as follows: Let m and n be perfect s u h
t such that, q are, t en there exist integers s and
Assume p is true, build steps using inference niles, with the
final step showing that q is true. m= s2and
In infonnal direct proof, we assume that p is true, and use n = t2
axioms, . definitions and previous theorems, together witb mn = s2t2 = (st)2
rules of mference to show that q must be true. . Hence, R.H.S, is

38 I lnsJghts on Discrete Structure lnsl&hts on Discrete Structure · I 39


Now, ab > ...fii,fii.
mn is a perfect square.
ab> n
ct proof
1.11.3 Indire hypothesis of a theorem to the ab/ n, which contradicts the original conditional statement
1 d from the . .h
Direct proo fs ea . th premises, contmue w,t a n = ab
· w1th e .
nclusion. They b egm d vith the conclus,on. We nceq
c O . and en " Proof strategy
sequence of de.ducuo~s, ms of the form 'v'x(P(x)-+ Q(x))
od Of roV1ng theore When we want to prove a statement of the form Vx (p(x) -+
other meth s P . this type that are not direct proofs, i.e., ·
Q(x)), first we try to prove by direct proof If a direct proof does
Proofs of theorem of th . and nd with the conclusion
that do not start with the hYPo es1s ' not see to go anywhere, try the same thing with a proof by
\l d 1·ndirect proofs. contraposition.
are ca e f proof by contraposition, proof
Example of indirect proo s are Definition

by contraposition. A real number is rational if there exist integers p and q with

p f by contrapos1t1on. ' . qi O such that r = p/s . A real number that is not rational is called
1.11.2.1 roo : d + 2 is odd, then n is odd. irrational.
l. If n is an mteger an 3n .
~ ) is odd then n is odd) 1. Prove that the sum of two rational numbers rational.
p-+q (if 3n , 2
.f . not odd then (3n + 2) is even) If r and s are rational numbers then to prove is r + s is also
-.q -+ ....,, (l D l S rational
let n is even, Let r = p/q and s = t/u where p, q, t, u are integers such that q
n=2k to and u i 0
now, 3n + 2 == 3*2k + 2 r + s = p/q + t/u = (pu + qt)/qu
=6k + 2 qutO
==2(3k + 1) Hence, r + s is rational (proof succeeded by direct proof)
Thus (3n + 2) is even . r 2. Prove that if n is an integer and n 2 is odd,
The negation of conclusion of conditional statement d1~~ I~ Then n is odd.
·mnal con 1non
that the hypothesis is false, so, the one.- Here, we first attempt by a direct proof. Suppose n 1s an
statement is true. rs integer and n2 is odd.
Prove that if n = ab where a and b are positive lntege n
2
= 2k + I
2.
then ~ ✓
nor~ ✓n n = ±v'2k + 1
Here, The above equation is not useful to show n is odd. Because
lf (n = ab) then (a~ ✓nor ~✓n) this attempt to use a direct proof did not bear fruit, we next
The contrapositive of p-+ q is~-+ --P have a proof by contraposition.
-,q - ,,
So,
~ means (a >✓n V b >✓
n)
Insights on- Discrete Structure I 41
40 I Insights on Discrete Structure
=6k + 2
if n is not odd then n2 is not odd
2· n = 2(3k + l)
if n is even then n is eve
Its even
~ n= 2k
2 Hence, our assumption came to wrong.
n2 = (2k)2 = 2k(2k) even
So, if 3n + 2 is odd then n is odd.
d. tion
111 2 2 Proof by contra ic . Q. Prove if ti is even then a is even (by contraposiave)
· • • ove that a statement p 1s true. SqppOSe
Suppose we want tod~\ion q such that""" p -+ q is true, only For p _. q the contrapositive is """q _. 7'
that we can find a contra ic So, the contrapositive g the given question is
when p is false that is p is trUe. .
If a is odd then a 2 is odd
For (p --+ q) we use (pA"""q) -+ F
a= 2k + l
r,; ti (prove by proof by contradiction)
1. v "' is irra ona1 a 2 = 4k2 + 4k + l = 2(2k2 + 2k) + 1 which is odd' (see the
difference in proof by contrapositive are proof contradiction)
Let ./2 is rational.
ented as a ratio of integer a and b such Hence proved.
Then 2 can b e rePres
d b have no common factor. If a2 is even then a is even.
that b i o. Where a an
a = 2c where. c is any integer
./2 = alb
2b2 = (2c)2
.,/zb=a
b 2 = 2c2
Squaring both side,
2b~=a
2 1.11.3 Vacuous proof
a2 is even number, so a is also even p _. q is true when p is false . If we can show that p is false
then we have a proof , called vacuous proof.
a=2c
We can quickly prove that a conditional statement p -+ q is
= :4c
2 2
Again, 2b true when we know that p is false, because p -+ q must be true
2
b2 = 2c when p is false. Consequently, if we can show that p -is false, then
b2 is even, b is even we have a prnof, called a vacuous proof, of the conditional
statement p _. q.
"'.b~
Both a an b are even, 2 divides both a and b . ..fi. = a/b.
a and b have no common factor it means 2 does not ~~de Q. Show that the proposition P(O) is true where the domain
both a and b. Because""" p leads to contradiction that 2 diVl c~nsists of the integer numbers and P(n) is "If n ~ 1 then
,. > n." Note: vacuous proof: when p is false p -+ q is
both a and b. so, """P is false. 2 is irrational. true, regardless of the yalue of q.
2. H 3n + 2 is odd, then n is odd. Solution:
Let us assume that n is even and,3n + 2 is odd. Note that P(O) is "If O > 1, then 02 > O." We can show P(O)
Then, n = 2k using a vacuous proof, because the hypothesis O > I is false.
Hence P(O) is automatically true.
3n + 2 = 3(2k) + 2
Insights on Discrete Structu,e I '3
42 I Insights. on Discrete Structure
1
1.11.4 Trivial proof . . 2
n = 41<2 + 4k + I
A proof of P - q that uses the fact that q 1s true
, .
1s called
2
n = 2(2k2 + 2k) + I
trivial proof.
q- p
By showing that q is true, it quickly follows that p ~ q rnus1
• of p _ q that uses the fact that q ts true is n = 2k
also be true. A proo f
n 2 = (2k)2 = 4k2
called a trivial proof.
n 2 = 2(2k2)
Q. Let P(n) is 'If a and b are positive ~ntegers with a ~ then
a• ~b• where domain consists of all integers. Show that p(O) if n is even, then n2 is even
is true. (proof by contraposition)
The proposition P(O) is ··If a~~ then a ~
0
?o"
Because "' a0
Q. Show that these statement about integer n are equivalent
bo = 1, the conclusion of the given cond1t10nal statement is pl : n is even
true. p2: n-1 is odd
Thus p(O) is true. p 3: n2·1s even
1.11.5 Proof by equivalence pl --+ p2, p2 - p3 and p3 - pl
To prove p - q show that p--+ q is true and q--+ pis true. · F~r pl--+ p2
The validity of this approach is based on the tautology Let n= 2k
(pH q) H [(p--+ q)A(q--+ p)] then n-1= 2k-1=2k-1+1-1=2(k-l}+ l=even+ l=odd
Example: Prove that if n is a positive integer, then n is odd il Forp2- p3
and only if n2 is odd. . Let n-1=2k + 1
Sometimes, a theorem states that several propositions are Then n= 2k+2
equivalent. Such a theorem states that propositions pl, p2, 02
= (2k+2)2 = 2(2k2 + 4k + 2)=e;ven
p3 ........ po are equivalent. This can
be written as 'pl+-+ p2+-+........+-1 2
po p3 --+ Pl i.e. if n is even n is even is proved earlier.

which states that all propositions have the same truth values Hence these propositions are equivalent
and consequently for all i and j with . l ~ i ~ n and 1 ~ j ~ n, pi and pl .H p2 H p3 - --- +-+ pn)H{pl - p2)A{p2-+ p3)A /\
pj are equivalent. (pn--+ pl) . ...

This can ® proved as following v (pl+-+ p2+-+ ........+-1 l.11.6 Proof by cases
pn)+-+{p 1 -+ p2}A{p2 --+ p3)A ..: .......... A(pn --+ p 1)
&, 11 Sometimes it is difficult to use a single argument that holds
Q. Prove that ''If n is an integer, then n is odd iff n2 is odd''. 1 or a cases. ·
p: n is odd
Proof by cases uses the following equivalence:
q: n2 is odd
[(pl Vp2 V· ··Vpn) --+ q]
q)]
= [{pl - q)A(p2 - q)A· ··A(pn -
p --+- q [T]
n = 2k + I Example: Prove that if n is integer then ni 2: n.

44 f Insights on Discrete Structure Insights oi, Discrete Structure I 45


We split the proof into three cases.
For n = 2, (n + 1)2= 32 = 9 and 3°= 3 2 = 9
Case (i) n = 0.
For n = 3, (n + I )2 = 43 = 64 and 3" = 33 = 27
In this case, n 2 =0 2 -- O=n· 4
For n = 4, (n + 1/= 53 = 125 and 3"= 3 = 81
Case (ii) n?: l . >
. multiply both sides of n _ l by n we In each cases, we see that (n + I)2 ?:3"
In this case, when we . 2
obtain n·n?: n· l . This simphes n ?: n. Mistakes in Proofs
Case (iii) n ~ - l. 2 What is the problem with the following proof that l = 2?
.
In this case, n ~ 1,
_ but 02 >
-
o. Therefore, n ?: 0 ?: -l ~ ~
Use the following steps, where a and bare two equal positive
2
and so n ?: n. integers.
n) _. q)= ((pl -t q)A (p2 -t q) .. ,.Jt I. a = b Given
\(plvp2v ......... vp
~-~ . 1 2. a2 = ab Multiply both sides of ( I) by a
•o-inal conditional statement with
This shows that the 000· . . 3. a2 - b2 = ab-b2 Subtract b2 from both sides of (2)
. f disiunction of the propostttons pl,
hypothes\S made up O a :i • f h 4. (a - b)(a +: b) = b(a - b) Factoring both sides of (3}
be roved by provmg each o t e n
p2, . .. ••···• pn can _P •_ 2 n individually. Sucl 5- a+ b = b Divide both sides of (4) by a-b
conditional statement P1 _. q, 1 - 1' ' · · · · 6. 2b = b Replace a by b in (5) , since a= b
an argument is called a proof by cases.
7. 2 = 1 Divide both sides of (6) by b Therefore 2 = l.
1.11.7 Exhaustive proof . Solution:
.This is a special form of a proof by· cases, when there IS I Step 5 where we divided both sides by a-b is invalid. The
finite and small number of examples for which we need to prove I error is that a - b equals zero; (Divide by Zero)

fact . h 1.12 Elementary Induction and Complete Induction


be roved by examining a re1attve .
Some theorems can S J f: are called exhaustive proo!
. . . . .
In weak mductton, we test the base case puttmg n=O or I and
small number of examples. udcb prooxhasusting all possibilities. It ~ assume that particular statement bolds at kth step, while in strong
be these proofs procee Y e . . .
cause fb mductton, we assume that the pamcular statment holds at all the
special type of proo Y cases. . ..,ith n <2. steps from the base case to k1h step. The difference between weak
" + J) 2 > 3" i' n is .a positive integer ,... - ·
QI. Prove that ,n - 'J • • n :::: l (elementary) induction and strong (complete) induction only
We use a proof by exhaustion, by exarrurung the cases appears in induction hypothesis. In weak induction, we only
2. assume that particular statement bolds at kth step, while in strong
1
For n = l ,(n + 1) = i2 = 4 ~ 3n= 3 = 3.
2 induction, we assume that the particular statment holds at all the
For n = 2,(n + 1)2 = )2 = 9 ~ J2 = 3".
th
steps from the base case to k step.
ove that fn + 1)2 ~ 3" if n is positive integer with n ~ 4, -Example of strong induction:
Q2. Pr {' 2
We only need verify the inequality (n + 1) ~ 3n Proposition: Ev~ry integer greater than I can be written as
When n = 1,2,3 and 4 the product of prime numbers.
For n = -\, (n + 1)2= 22= 4 and 3n = 31 = 3

Insights on Discrete Structure I 47


46 I,Insights on _Discrete Structure
Let P(n) be the statement that n can be written as the product ·
of prime numbers. I. Show that if n is .. .
a positive integer then
Then the proposition says: P(n) is true for each integer I + 2 + ... .+ n =n(n+1)
2
greater or equal to 2.
~et p(n)_be the proposition, that sum of the I s1 • •

Proof (by strong induction): integers 1s n(n + 1)/ 2 n positive


1 Base case: 2 is a prime, so it is the product of a single prime. Basic step: p( I) is true because
2. Strong inductive step: Suppose for some k ~ 2 that each I = I ( I + I )/2 = I
integer n with 2 :S it :'.S k may be written as a product of Tnductive step :
primes. We need to prove that k + 1 is a product of primes.
Assume p{k) is tru f◄ .

Case (a): Suppose k + 1 is a prime. Then we are done. e or an arbitrary positive integer k, 1· e
I + 2 + 3+ .....+ k = k(k + 1)/2 . · ·
Case (b): Suppose k + 1 is a not prime. Then by the fact
Now, we have to show p(k + l) is tru .
stated above, there e~ist integers a and b with 2 :5 a, b ::; i I 2 e, t.e.
such that + + 3 + ....k _+ (k+ l )=(k+·I)(k + 2)/2
L.H.S. =I+ 2 + 3+....k+(k + I)
k+ I =,a· b.
= k (k + J)/ 2 .
+ (k + l) (inductive hypothesis)
By the strong inductive hypothesis, since 2 :5 a, b :5 k, both 1
and b are the product of primes. Thus k + 1 = a · b is tlx = k (k + l) + 2k + 2/2
product of primes. = k (k + I) + 2(k + l )/2
Mathematical Induction =(k+ l)(k +2)/2
From the · · I ·
Mathematical induction is a means of proving a theorem ~- . . pnnc1p e of mathematical induc . .
all positive integers n. tion, p(n) 1s true for
showing that if it is true of any particular case it is true of the nex:
case in a series, and th<,m showing that it is indeed true in ol'.i 2. Conjecture a formula for the su
particular case integers. Then pr.,. m of the .first n positive odd
, vVe your COnlj"ectu •
induction. re US,ng mathematical
Suppose we have some statement P(n) and we want u
demonstrate that P(n) is true for all n. The sum of the fi t ··
are rs positive odd integers for n == l 2 3 4 5
To prove that p(n) is true for all positive integer n where p(o , , ' ,
is a propositional function then we do two steps l == l
1+3=4
Basic step: we verify that p(O) or p(l) is true
1+3+5 = 9
Inductive hypothesis: we assume that p(k) is true I + 3 + 5 + 7 = 1.6
Inductive step: we prove p(k + I) is true I + 3 + 5 + 7 + 9 = 25
We show p(k) -+ p(k + I) is true for all positive integer! Hence the su f h
assuming p(k) is true (Inductive hypothesis) I + 3 + 5 + m o t e fir!t n positive odd integers is n2 i.e.
.. . (2n-l) = n
As rule of inference, this can be stated as, Let p(n) denote the proposition th ..
[p(l) A Vk(p(k)-+ p(k + I)]-+ Vnp(n) . positive odd integers is n2 at the sum of the .first n

48 I lnslghts·on Discrete Structure · Insights on Discrete Structure I 49


Basis step : p( l) is true a
4. ~n aT=ar
I- JI 2
.... +al'= arn+l -aawherer-#
l = i2 (is true) £-t=O =a+ar+ar+
I r-t
. Inductive step : let p(k) is true, i.e. 1 + 3 + S+ · .. · + (2k-l)::::
k 2 is true. Basis step : p(O) is true as
Now, p(k + l) is the statement ar 0 + 1 - a = ar-a :.:._ a(r-1)
r-1 H - ~ =a
l + 3 + S+ .... ... + (2k - 1) + (2(k + l )-1) = (k + l )2
Inductive step :
l + 3 + 5+ ..... .. (2k - l) + (2k + 1) = (k + 1)2
let p(k) holds for k, where k is non negative integer. i.e.
Here, _1 .1:. ark+i_a .
a+ ar+ ar +.. ... +ar = -r-1
- - 1s true
1 + 3 + 5+ ........ +(2k-l) + (2k + l) = k2+ (2k + l)
2 .Now p(k + 1) is the statement.
k2 + (2k + 1) = k + (2k + l)
a+ ar + ar2 + . .... +al+ al +'= arU< + i) + i_a ar<k + 2La
k2( inductive hypothesis) r-1 r-1
P(k)-+ p(k + 1) is true, p(n) is true for all positive integers n L.H.S. =a+ ar+ ar2+ ..... + al'+ al+1
ar<k + 1) -a
3. S!towthat = al +'
r-1
r
J + 2 + +.. .... + r =r +
1
-1 for all non-negative integers. _ ar<k + l )_a+ar<k + 2>-ar<k + 1)
r-1
Let p(n) be the proposition ar<k + z)_a
1+2+2+ 2
........ + 2n-2n
- +ll
- r-1
• Basis step : p(O) is true as ~(k) -+ p(k + 1) is true, p(n) is true for all non-negative
1 mtegers.
L.H.S.= 2°= land R.H.S. = 2°+ -1 = 2-1 = l
L.H.S.= R.H.S. 5. · Prove n<1" for all positive integers n.
Let p(n) be the proposition that n<2°
Inductive step :
1 Basis step : p( l) is true as 1<2 1 = 2 is true
Let 1 + 2 + 22+ ....... + 2k= 2k+ -1 holds fork
lnd~ctive step : assume for positive integer k, p(k) is true, i.e.
Then, p(k + 1) is k<2 •
} + 2 + 22+ ...... + i' + 2k +I= z{k +I)+ I-} = 2k + 2- }
p(k + l) is the statement (k + l) <2k + l
Now, we have, k<2k
1 + 2 + i2+ .... + 2k+ 2k+ 1=(2k+ 1-1) + 2k+ 1(using inductive k + I< 2k+ 1 ( adding both side I)
hypothesis) note that I <2k ·
= 2.2k + 1-1 = 2k +2-1 k + 1 < 2k+ 1
P(k) .- p(k + l) is true <2k+ 2k
P(n) holds for all n(all non-negative integer) <2.2k
<2k+I

Insights on Discrete Structure I 51


50 I lnsi,trts on Discrete Structure
k + l<i' + I
. (.k + l) is true, .p (n) is true for all positive 2: ( l+k/2)+ I/2
Smee p(k)----+ P 2:( I +(k+ I )/2)
integer n. .
'fi rypositive integer n with n>4 8. Prove n 3-n is divisible by 3 wherever n is a positive integer.
6. Prove that t' < n. or eve
Let p(n) denotes n3-n is divisible by 3
Let p(n) be the proposition 2"<n! . .
. i4 =16 <4! = 24 Basis step: p(l) is true as 13-1 = 0 is di.visible by 3.
Basis step: p(4) 1s true as .. . . Inductive step : let p(k) is true, i.e. k3- k is divisible by 3 for
.. . . L t (k) be true for pos1t1ve integer k with k
lnducttve step • e P a positive integer k.
>4 i.e. 2"< k! Then, p(k + I) is the statement (k + I )3 - (k + .1) is divisible
1
;(k + l) is the statement 2k + <(k + l)! . . by 3.
k +1 _ k = 2 2" < 2.k! (inductive hypothesis) (k+ 1}3-(k + l)=(k3 + 31< + 3k + 1)-k-l
we have, 2 - 22 ·
<(k + l)k! , (2<(k + 1)) = (k3 - k) + 3(1<+ k)
< (k + l)! Factorial definition. (k3-k) is divisible by 3 (from hypothesis) and 3(k3+k) is also
divisible by 3 and so 'their sum is also .divisible by 3.
Hence, 2" + 1< 0c + l)!
P(k) ___. p(k + l) is true_,p(n) holds for all 1!2:4 P(k) --+ p(k + 1) is true p(n) is true for a positive integer n.

. ua/ity fior harmonic numbers. The harmonic 9. If S is a finite set with n element where n is a non-negative
7. An ,neq . med b H · = 1 + 112 + integer, then S has 2" subsets.
numbers H), J = 1, 2, 3, ...•.. are deft 1 1
Let p(n) be the proposition that a set with n elements has zn
1/3+..•... + 1/j
subsets.
Show that H/ ~ 1 + n/2 where n is a non-negative integer.
Basis steps : p(O) is true, because 2° = l subsets which agrees
Solution: with the fact that a set with zero element i.e. empty set has
Let p(n) be the proposition that H/2:1 + 0/2 only one subset namely itself.
Basis step, Inductive step : we assume for non-negative integer k that
every set with k element has 2k subsets. p(k + l) is the
H12: l
statement that every set with k + l elements has 2" + 1 subsets.
l 2: 1
Inductive step : assume p(k) is true H/ 2:1 +k/2 for a non· Let T be a set with k + 1 elements, then we can write T =S u
, I
negative integer k. . {a} where a is one of the element ofT and S = T-{a}
1
Then p(k + 1) is the statement H 2k+ 2: l +(k + l )/2 (ISi = k) subsets ofT ean be obtained in the following way
Now from definition of harmonic number For each subsets of there are exactly two subsets of T,
' ~
H/+ 1= 1 + l/2 + 1/3+ + (1/2")+(11:!"+l)+(l/2"+2)+ ... +l/2 namely, X and XU {a}, these constitute all the subsets of T
= H/+ (112"+1) + (112"+ 2) + ... + 1/2k+I and are all distinct.
?_ (l+k/2) ·+ (1/2"+ 1) + (li2"+2) + .. .+1/zk+I · But there are 2k subsets of S, so there are 2.2k = 2k + 1 subsets
ofT.
2: (1 +k/2) + 2"*(112"+!)
Insights on Discrete Structure I 53
52 I Insights on Discrete Structure..
S -{
- a, b} T=={a,b,c} 1.13 Consistency and Completeness of the.System
X == [ {} ' {a} ' {b}, {a, b}] valid Formula ,
T == {a, b, c}
Valid formulae are those formulae which are valid under all
valuations (pv-.p) is valid formula. Valid propositional formulae
SubsetofT U{c} {b}U{c},{a, b}U{c}) are caUed tautologies.
== [ {} ' {a}, {b} , {a, b} ' {} U {a} , {a} '
Satisfiable Formula
.zation of proof techniques
Eumm
S Proof Approach to Remarks These can be made true under at least ~ne valuation, thou~
not necessarily all valuations. An example of satisfible formula ~s
N.· Technique prove p-+ q
pvq which is true at p = T and q = F. Every valid formula 1s
satisfiable.
1. Exhaustive Demonstrate p May only be used for
Unsatisfiable Formula
proof -+ q for all finite number of cases
possibilities The unsatisfiable fonnulas come out false under all valuations.
2. Direct proof Assume The standard approach S~undless and Completeness of the system
p, . t try
deduce q usually the thmg o •
The axioms are all valid and each inference rule has the
following properties: If both premises are valid then the conclusion
3. Proof by Assume ~q, Use this q i(. as . a is also valid. It follows this, that, only valid formulae can be proved
contraposition derive-,> hypothesis seems to give in a sound logical system.
more ammunition then q
would. If (j) can be proved in a sound logical system then <I> is valid.
If there is a proof of (j) then <I> is called a theorem.
4. Proof by Assume P-"~q, Use this when q says
contradiction deduce a something is not true The soundless of a logical system is expressed as
contradiction If (j) is a theorem (if (j) can be proved), then cj> is valid.
5. Vacuous proof Show p is false Give an example to inake The completeness of the system is expressed as
pis false, in p-+ q.
If cj> is valid then (j) is a theorem ((j) can be proved)

6: Trivial proof Show q is true Give an example to make 1.14 Method of Tableaux
q is true.
The main problem with the axiomatic system. we have
described is that although it is relatively easy to check that a proof
7. Proo_f by cases Demonstrate p May only be used ~for of a fonnuJa is correct, it is much harder to can:;,truct a proof. We
- q for all cases known cases. need intuition to know which axioms to pick and when to apply

LL----:-+-__:_--+-~-:-------:HPJ
8. Proof by To prove pHq (p1HP2Hp3. .... )
- modus ponens. It is even . worst, if you do no_t know whether a ·
fonnula can be proved or not.
equivalence show (p -+ H(p1 -+ P2)A(P2 -+ P3 .. ...
It is the method to prove the satisfiabilty of a s'e t of fo~ula.
q)A(q-+ P) · A(pn-+ Pt)

54 I Insights on Discrete Structure Insights on Discrete Structure I S5


Reasons for using tableau l. <I> =..., ...,B
• It is quite easy to use (though some may argue, that natural
2. ct> = B/\C
deduction is easier) and
It is very suitable for implementation on a computer. 3. cj> = ...,(B I\ C)
• It breaks each formula into component upto simplest one, 4. cj> = (B v C)
• where contradiction is easy to spot. 5. <I> = ...,(B v C)
6. <I> = (B --+ C)
It creates a tree strUcture called tableau.
• 7. <I> = ...,(B --+ C)
Parsing 8. cj> = (B H C)
When we ~arse a formula, we look at the string of symbols
9. </> =...,(B H C)
and work. out how it was built up from the propositions. In other
words, we recover the strUcture of the formula. The term comes Derivation Rules in Tableaux Form
from linguistics where the act of parsing is to determine the I. ..., _,B 2. 8 /\C
grammatical strUcture of a sentence of natural language.
B
I I
Example B
..:. Let q, be the f~nnula (pAq) v(7>"-iq) then we can parse as C
(p /\ q) V (p /\ q) 4. (BvC) 5. ...,(B vC) 6. (B-+ C)
~ - I\
B C
I
...,B /\
_,B C
(pAq) (7)A-,q)
I I -c
p 7. ~B--+ C) 8. (BHC) 9. ..., (BHC)
q
I
Tableaux method
Note:
B
-c
/ \....B
C -c
A
-c C
If only set of formula is given (i.e. conclusion is n~t given~ Some derivations:
I.
if any branch is open, then the set is satisfiable sometime! (BHC) = (B --+ C) I\ (C --+ B)
called soundness. =(-iB V C) I\ (-CV B)
2. If the argument (i.e. premises .and conclusion) are given, \It
== (-iB" -C) V (-,B B
negate the conclusion. If the all branches of tree (made up J = r I\ ) V ( C I\ -.c) V (C /\ B)
premises and negatfon of conclusion) then it is valid call~ - (-,BI\ -C) V (CI\ B)
completeness. = (BA C) v (...,BI\ -.C)
=-, ((B /\ C) V (...,B /\ -C)]
Tablec1;ux construction rules
=...,CB/\ c) /\..., c-.a I\ -.c)
If a formula «I> is not a literal, it has one of the followi~ == (...,B v..., C) /\ (B v·c)
forms.
Insights on Discrete· Str_ucture I 57
56 I Insights on Discrete Structure
=(-.B "B) v (-,B "C) v(-C "B) v(-.C /\ C)
= (B "-C) "'.(-.B "C)
Steps in Tableaux method
.i. "'-- . '1>m a tableau for .t. $m
G' finite set of fonnu las"'" '+"L>"..
iv:::tree of formulas constructed as follows:
11>2,• •"' q,ffl I
· , 1,

B
/\-.s
l. First of al\, list the formulas
C -C
'1>1 -,c -,c
~ D D
q,3 4. After each step, we check for satisfiability along branches.
Thus, the left- most branch contains a formula and its
· negation, namely, C and -C.
There are, the left-most branch is not ·satisfiable. So, we can
'Pm . . l close-off this b~ch and we will not analyze this
Starting from any formula oi, apply the denvat1on ru e, say further.(indicated by bar)
2.
q,;= ca--c) Note that we will not apply further derivations rules to it.
We apply the previous steps along each branch that is not yet
q, l
closed off until either
q,i i. Every branch is closed or
ii. All non-literals along each unclosed branch is checked.
Then in case (i), the initial set q, 1, q, 2 , ..... q, m is not
satisfiable. On the other hand, if (i) fails that is some
branch is not closed off but (ii) holds, then the set of
formulas q, l, q, 2, . .... q, m is satisfiable.

B
A -.a
5. From open branch we can check for validity by valuation.
For all literals p we define valuation Vas
V(p) = T ifp appears along the branch
C -C rt 1 = F if p appears along the branch
Now' along each branch of the tree constructed hithe o,
3.
repeat the previous steps, say cl>;= (-CAD) =Tor F if both p and 7> not appears in branch
Q. Consider the set ; ={(PA-.Q) -+ S, -.Q v-,R; PAT}
4>1 I •
A tableaux for q,

lnslghu on Discrete Structure I 59


· · 58 I Insights on Discrete Structure
(PA--.Q)- S
Completeness
--.Qv-,R
When we say that the tableau method is complete we mean
PAT that if cl> is any valid formula then you can construct a closed

A tableau for --. cl>- This means ~hat any valid formula can be pr~ved

;<:)A using the tableau method showing completeness is usually the hard
part to check for most inference systems.
Corollary:

A71-i
-,iQ pp
If a completed tableau for a formula cl> is open, then cl> is
satisfiable. If a completed tableau for cl> is closed, then cl> is

1 P
A T (5)T (6)
p --.Q --.R
unsatisfiable.
By following corollary and the two theorems we know that
the tableau method is both sound and complete.
·

I T (3) (4) .
Definition:
<•) c2) r An argument
\ Al
For open branch (4) A2

V(T)=T
V(P)=T An
V(R)=F B
V(S)=TorF is said to be valid if the conclusion B is a tautological
V(Q)=T consequence of the premises Al , A2, .. .. ...An
Then Now, {Al, A2, . ...... An}=B

V((P " -Q) - S) = T Q. P-(QAR)


V(--.Q v --.R) = T Q-+S
V(P "T)=T R-+A
--.p-+ B
Soundness of propositional tableaur I
When we say that the tableau method is i(mnd we mean {hat (SAA)vB
if you can construct a closed tableau for --. cl> th~ cl> must certainly This argument is valid iff for any valuation 'V' satisfying the
valid formula. This means that anything we prove by the tableau hypothesis, V also satisfied the conclusion. Or in other words if the
10
method is certainly valid. Soundness is usually the easy part hypothesis plus the negation of the conclusion is not satisfiable. So,
check for most inference systems. we check for satisfiability.

Insights on Discrete Structure I 61


60 I lnsiahts on Discrete Structure
P-+(QAR)
o-s
R-+A "A student in this class has not read the 6ook ", and
J.
--.p-+ B "Everyone in this class passed the first exam" implies that,
conclusion "someone who passed the first exam has not
~(S\A)vB) read the book." [2076 Baisakh, Back/
-.a Solution:
~SAA) Propositions:

~B
C(x): x is student in this class
R(x): x has read the book
~P P(x): x has passed the first exam
\ Hypothesis:
p
3x(C(x) "--.R(x))
/
~
--.p (QAR)
Vx(C(x) --+ P(x))
Conclusion:
\ 3x(P(x) /\--.R(x))
Q S.N. Statement Reason
R l. 3x(C(x) A ---R(x)) Hypothesis
~ 2. C(a) /\ --.R(a) Using Existential Instantiation in 1.
-Q s
3. \fx(C(x)--+ P(x)) Hypothesis
~ 4. C(a)--+ P(a) Using Universal Instantiation in 3.
--.g -.A

~A
--.R
5.
6.
C(a)
P(a)
Using Simplification in 2.
Using Modus Ponens in 4 and 5.

Every branch closes hence the argument is ivalid. 7. --.R(a) Using Simplification in 2.
8. P(a) /\ --.R(a) Using Conjunction in 6 and 7.
9. 3x(P(x) "--.R(x)) Using Existential generalization in 8 .

2. Using rules of inference, prove that the hypotheses "If I get


my Christmas bonus and my friend are free, I will take a
road trip with my friends.", "If my friends don't find a job
after Christmas, then they will be free." and "I got my

62 I Insights pn Discrete Structure ~nslghts on Discrete Structure i 63


Ch . tmas bonus and my friend did not find a job aJtt,
Ch:tmas " Lead to the conclusion "1 will take a road trip q: I will have a test in Discrete Structu
with my friends." Io73 Bhad,111 . re
r: I w1 1I have a test in Microproc
essor
Solution: s: My Microprocessor teacher is sick
Propositions: Premises:
p: I get my Christmas bonus p-+ (qVr)
q: My friend are free S-+ -,r
r: I will take a road trip with my PAS
s: My friend find a job after Christmas Conclusion:
Hypothesis q
{pAq)-+ r, --S-+ q, pA--S Puttinng in clause fonn:
Conclusion cl :--pV(qVr)
Disjunction fonn of premises p-+ (qVr)
r c2: ---,sV-,r
Disjunction fonn of Premises s -+ -,r
S. N. Statement Reason c3:p From premises pAs
1. """'S-+ q Hypothesis c4: s From premises pAs
2. P"---,s Hypothesis cS: -,q Neagating Conclusion
3. """'S From 2 Simplification c6: :--pvqv--s From cl and c2
From 1 and 2 Modus Ponens c7:qV---,s From c3 and c6
4. Q
p c8:q From c4 and c6
5. From 2_Simplification
c9: T From c7 and c8
6. P"q-+ r Hypothesis
4.
7. p/\q From 4 and 5 Conjunctions Use
~- resolution
h to show the hvnnthesis
'Jr-
""'t
1.1
,s·
not raining
•. or
.:,lta as her umbrella," "Sita , 1 _ _ L-.
IWQ. not ,..,ve her umbrella
8. R From 6 and 7 Modus Ponens or she does not get wet., " and ""'t . . . •
• 1.1 ,s raining or Sita does not

3. Using resolution prin~iple, prove that the hypotheses "t .get wet" imply that "Sita does not wet." (071 Bhadra]
today is Tuesday then I will have a test in. Discrd Solution:
Structure or Microprocessor". "If my Microprocess#_ r: It is raining
teacher is sick then I will not have a test P u: Sita has her umbrella
Microprocessor." and "Today is Tuesday and ,: w: Sita gets wet
Microprocessor teacher is sick. " lead to the conclusion lkl
hypothesis:
"I will have a test in Discrete Structure". {072 Ash~
--rvu, """'l.lV-w, rV-w
Solution:
Conclusion:
Propositions:
-w
p: Today is Tuesday
64 I Insights on Discrete Structure Insights on Discrete Structure I 65
Putting in clause fonn 5. J(a) Using simplification on 3.
hypothesis
cl:-,vu 6. W(a) Using modus ponens on 4 and 5.
hypothesis
c2:---uv-'W 7. C(a) Using simplification on 3.
hypothesis
c3:rv-'W 8. W(a)/\C(a) Using conjunction on 6 and 7.
negating conclusion
c4:w
from c \ and c2 9. 3x (W(x)/\C(x)) Using existential generalization on
c5: -,rv-.w 8.
from c3 and c6
c6:-""'W
from c4 and c6 6. Let Q(x, y) denote (x + y = 0). What is truth values of
c7: Y quantification ~ lfxQ(x, y) and lfx~Q(x, y). /2076
hence the argument is true. Baisakh, Back/
' . rules 0 r inference to show
rgu1ttent using 'J • Solution:
5. Construct an a esis "all 1ttovies produced a movie art
that the hypoth duced a ,,.0 vie about coal Here,
..1-J.,1 John Sayles pro .
wonue•J-· . "There is a wonderful mo\llt Q(x, y) denotes x + y = 0
. ,, • ply the cone1uswn,
miners ilft . " You are required to show each step 3yv'xQ(x, y) means that " There is a number y such that for
about coal miners. h steps be/ore you come to tht every real number x, for Q(x, y) i.e. x + y = 0.
and give reasons for t ose th . /071 Maghj
desired conclusion from the hypo esrs. It is false when for all value of y, there exists a x such that
Q(x, y) is false.
Solutwn:
J(x): x is movies produced by Jolin Sayles It is true when there exists a y such that Q(x, y) is true for
every x.
C(x): x is movie about coal miners.
v'x3yQ(x, y) means that "For all real number x, there is a
W(x): x is wonderful movie. real number y, such that Q(x, y) i.e. x + y = 0 .
Hypothesis: It is true when for every value of x there exists a y such that
v'x(J(x) .- W(x)), 3x(J(x)/\C(x)) Q(x, y) is true.
Conclusion: It is false when there exists ax such that for every y Q(x, y)
3x(W(x)/\C(x)) - is false.

S.N. Statement Reason ~ 7. Using mathematical induction technique, prove· that the
following statement is true: 3 + 3*5 + 3*51+3*5" = 3(5"+_
1. v'x(J(x) .- W(x)) Hypothesis - 1)/4 whenever n is nonnegative integer. {072 Ashwin]
2. 3x(J(x)/\C(x)) Hypothesis
---
Using existential instantiation on
Hints:
p(k+ 1) =3*(5k+l_l)/4+3*5k +I
3. J(a)/\C(a)

4. J(a)- W(a)
2.
· ---
· ftonon 1.
Using universal mstantla
= (3*(5k +1-1) + 12*5k +1)/4
= (l 5*(5k + 1)-3)/4

Insights on Discrete Structure I 67


66 I lnslghp on Discrete Structure
The negation of conclusion of conditional statement implies
::: (3*5*(51< + ')-3)/4 that the hypothesis is false, so the original conwtional
- 3•(S1t +2.1)/4 . statement is true. ·
- (...,B v...,C )} unsatisflabilityoJ

8.
if
Show that {A /\ C, (·.,A v B~ tableaus. Prove that " If nii 9. Use mathematical induction to prove that 1' + +If" + is
divisible by 57 for every non negative integer n. [2076
2 1

the given set using ,ne~h~; then n is odd. {2076 Baisakh,


an integer and 3n + 2 ,s ' Baisakh, Back/
Back] Solution:
Let P(n) denotes 7" + 2 + 820 + 1 is divisible by 57
Solutions: AAC
Basis step:
(-.AvB) 1'-(-.B v-C)
P(l) is true as 7° +2 + s2•o+ 1= 49·+ 8 = 57
I Inductive step: Let P(k) is true
-i.e. 7k + 2 + 82k + 1 is divisible by 57 for ev~ry non-negative
integer k.
Then P(k + 1) is the statement 7Ck + •> + 2 + 82(k + •> + 1 is
divisible by 57
7(k + 1) +2 + g2(k+ I)+ I
= 7k +2 ?1+ g2k + 182
= ?1• 7k+2 + g2k +1. 64
A = 7•7k +2 + 7*82k+ I + 57•g2k + I
= 7*(7k +2 + g2k+ I) + 57*82k+ I
C
It is divisible by 57 because in first part (7k + 2 + g2k + 1) is
divisible by 57 as from inductive step and in second part is
-,c multiple of 57, so the second part is also divisible by 57. So,
7n +2 + g 2n + I 1s
. d'1v1s1
. 'ble by 57 ~1or every non negative integer
In all branches there is proposition and its negation exists,I n.

it is_unsatisfiable. 1O. Use mathematical induction to show that 6 divides n1--n


whenever n is a non negative integer./071 maghj
Here,
Solution:
p _. q(if 3n + 2 is odd then n is odd) ·
Let p(n) denotes "n3-n is divisible by 6"
~ _.-. p(if n is not then 3n + 2 is even)
Basis step:
Let n is 'even, P( 1) is true as 13.: 1 = 0 is divisible by 6.
N=2k Inductive step:
Now, 3n + 2 = 3*2k + 2 ~et p(k) is true, i.e. l<-k is divisible by 6 for a non negative
=2(3k+ l) mtegerk. .
Thus 3n + 2 iS, even
Insights on Discrete Structure I 69
68 I Insights on Discrete .Stnu:~ure
k + l )J-(k + l) is divisible = (k + 1)2(k2 + 4(k + 1)/4
. the statement ( == (k + l )2<k2 + 4k + 4)/4
Then, p(k + l) is ·
== (k + 1)2(k + 2)2/4
by6. 3 31<+3k+l)-k-l
== ((k + l )(k + 2)/2)2
(k + 1)3-(k + l): ; 3~ k) + 3(k2+ k) ==R.H.S
_ 3 _ k) + 3k(k + l) 3 P(k) _. P(k + l) is true, p(n) is true.
- (k hypothesis)and 3k(k + \)
. . "bl by 6 (from be J2. If P == F, Q == T, S = T, R == F, then find truth value of
Here, (k3-k) is d1v1s1 e e k(k + 1) is always even num r
a. (S - (P/C'R))A((P-+ (RVQ))AS)
is also divisible b~ 6 ~ca:r lf k is odd then (KH) becomes
k is non neganve mteg · . 1 k(k + 1) becomes even. b. ((PK'Q)-s(QAR)) -+ (SV-.Q) /071 Magh/
as . . ven then obvious y . .
even and 1f k 1s e b r so we can write 1t as Solution:
Since k(k + l) is al~ays even num e ' ' a. S-+ (P"~R))A((P-+ (RVQ)),,..S)
2n where n is some mteger. = (T-+ (F"~F))A((F-+ (rVT))AT)
Then, = (T-+ (FA T))A((F-+ T)AT)
p(k + l) == 6M + 3.2N = (T - F)A(T /\T)
= 6(M + n) =FAT
=F
= 6A. . p( ) . true for a non negative integer
p(k) _. p(k + l) is true, n is b. ((PA---Q) - (QAR))-+ (SV-.Q)
n. = ((FA~T)- (TAF))-+ rrv-.T)
· h -:caJinduction to show that = ((FAF) - (F))-+ (TVF)
11. Usemat emuu
[071 Bhadra}
t'. + t 3
+ •••••• + n == [~(n + 1)/2 =(F-F)-+T
=T-+T
Solution: 3 3 + 1)/2]2 =T
_ Letp(n)denotesi3+2 + ......+n==[n(n .
13. State the converse, contrapositive and inverse for the
Basis step conditional statement, "I go to the beach whenever it is a
... p(l) is true as i3==(1(1 + 1)!2/ sunny summer day." [071 Bhadra/
1 == 1 Solution:
Inductive step: P : I go to the beach
Let p(k) is true, i.e. · Q: it is a sunny summer day
1
t3+ 2 +.....+k3== [k(k + 1)/2]2
3
Converse: q-p
Then p(k + 1) is · Whenever I go to the beach, it is a sunny day.
13+ 23 + 33+.....+k3+.(k + 1)3 == [(k + l )(k + 2)/2]2
Contrapositive: q-p
L.H.S Whenever I do not go to beach, it is not a sunny summer day.
}3+ i3+ 33+.......+k3+(k + 1)3 '
== (k(k + 1)/2}2+(k + 1)3 Insights on Discrete Structure I 11

70 I Insights on Discrete Structure


Or . t
If I do not go to the t,each whenever it is no a sunny summer
Finite State Automata
day.
Why is a tableau method ;,nportant in proposition logic?
14. Draw the tableau/or the formula
2.1 Sequential Circuits and Finite State Machine
2.1.1 Combinational circuit and S equenti·a1 circuit
.
;= (pA-,q}-+ S
Where ..denotes the nagation of a variable, A denotes tht . Combinational circuits have no . .
conjucdon of variables and -+ denotes the implication. their output depend only on th memory or mterm states,
. e current values of their inputs.
[071 Bhadra/ Sequential circuits contain mem .
states. The output depends no t onJ y on its
. ory element or internal
current . b
Solution:
Tableau method is important in propositional logic because it the past history of _those inputs. mputs ut also on
is quite easy to use and suitable for implementation on a
Finite state machines have int .
computer. depend not only on its c . emal states, so their output may
urrent mputs but also th
Tableau method breaks each to use formula into components past history of those inputs. on · e past state or
upto simplest one, where contradiction is easy to spot. This
method create a tree structure called tableau, which make 2.1.2 Finite State Machine
easy and unambigious solution of the problem.
. . _A finite state machine is a .
When we parse a formula, we look at the string of systellll pmruttve internal memory th t ~omputatton model with a
and work out how it was built up from the propositions. in or software and can be used ta c~ be implemented with hardware
0 stmulate sequenti I I ·
other words, we recover the structure of the formula. computer programs p · . a ogtc and some
anguag~s. . mtte state auto mata generate regular
The main problem with the axiomatic system is that although I
it is relatively easy to check that a proof of a formula ii
correct, it is much harder to construct a proof. We need Definition
intuition to know which axioms to pick and when to appl)'1 A finite state machine M consists of
modus ponens. It is ever worse ifwe do not know Wbether :· A fin'.te set I of input symbols.
fonnula can be proved or not. . A fimte set O of output symbols.
Now, c. A finite set S of states.
cj)= (pAq)-+ S d. A next state function f from SXJ . S
As since (pA--iq) - s = -iJ>A--iq)Vs e An
.
into .
output function g from SXI into 0
f. An ~nitial state ·
--,PA-iq} S
We write M = (I O S f g ~)
A
1
Example ' ' ' ' 'v

-v Let I= {a, b} ,O= {0,1} andS= { cro. 01}

Insights on Discrete Structure I 73


72 I Insights on Discrete. Structure
Define the pair of functions .
- The string

SXl -+ o by the rules given below Y1 ••·· ····Yn


tSXl -sand g: g . is the o/p string for M corresponding to the i/p string
f X1 .. ...... Xn
b a b
Sil a If there exists states cr0 , .. ...... O'n e s
o, 0 1
Oo Oo With cro-,, cr
1 0
o, o, 01 O'i . f( O'j.1, x;) for i = 1,...... , n
Y; s g(O'i-1, X;) for i = 1, ......, n
Then M = (I, 0, S, f, g, ao) is a FSM
Example
f (cro, a)= cro g(cro, a) = O
1. Design a FSM that performs serial addition serial adder
f (cro, a)= crl g(cro, b) = 1 accepts pair ofbits The Vp set will be· {00,01,10,11}
f (crl , a)= crl g(al , a)= 1 The olp set is {0,1}
f (crl, a)= crl g(crl, b) = 0 Given an Vp x, y
i. either add x and y or ii. add x, y and 1
Transition diagram Depending on whether the carry bit was O or l. So, we have
The tranSition diagram is a digraph. The vertices are th
two states c (carry) and NC (no carry). The initial state is
states. The initial state is indicated by an arrow. If we are in ~tate1 NC.
and inputting I causes output O and moves us to s1:3te a , w. Transition diagram:
draw a directed edge from vertex a to vertex a' and label it i/o. 01/0
01/l
all
l l//0
10/0
b/1

b/0
10/ 1 00/1 11/1

The SR trID fl 00
Let M = {I, 0, S, f, g, cr } be a FSM. The transition dia~
s R Q
of M is a diagraph G whose vertices are the members S. an aJtl1
l 1 Not allowed
designates the initial state. A directed edge (crl, cr2) exist in G.1
there exists an input I with f(a 1, i)= cr2. In this case, if g( o 1, i) " 1 0 l
The edge (cr 1, a2) is labeled i/o. 0 1 0
0 0 l ifs was last equal to I
Definition 0 ifR was last equal to I
Let M = (I, 0, S, f, g, a) be a FSM. An 1/P string for M~
string over I. lnslahts on Discrete Structure I 75

74 I lnsiihts on ~ete Structure


00/01
10/1 If we are in state O th 1
00/0 o ' e ast output 0
stale o , or Oz the last o/ was · If we are in either
' P was I Th A·
states are o 1 and 0 2• • us is FSA. The accepting
01/0 b a

Set means output =l


b
Reset means output = 0 Q. Draw the transition d .
· iagram of th FS'A
diagram ofa FSM e as a transition
2.2 Finite State Automata b/0
Finite state automaton is a special kind of FSM. It has no
output and no output function but has accepting or final state.
A FSA A = {L 0 , s, f. g, a} is a FSM in which the set of o/p
symbols is {0,1} and where the current state determines the last
outl)1'.,L Those states for which the last output was 1 are called
accepting states.
_E.g. The initial state is CJo
f g
s/1 a b a b b

<Jo 01 <Jo 1 0
01 02 CJo I 0
I 02 <Ji <Jo I 0 a/I
b/0

a/1

b/0 Oz is an accepting states


Its incommg
· edges with a and b
b/0 The ~ther states oo and o, are n~t ace .
have incoming alo .h eptmg state so that they
--. ng wit onJy a.
--:7'66~1111nsw,ts~;;;;;~o;nn01scri::::ete:::--:Structu::-~,.-------------
~ lnsl1hts on Discrete Stni~re I 77
Definition . . 'lar to finite state machine but
A finite state automaton lS Slffil .
f tates called accepting or finai a. cro= a
with no output, and w1'th a set o s .
b. f(o;.1, x;) = a; for i =I, .......... , n
states. FSA can be regarded as. C. OnE A
A finite set of input symbols (I)
1. ymbols (S) . We say that a is accepted by A. The null string is accepted
A finite set of states s iff a EA.
2. . f from SXI mto S.
A next state functton Is the string ahaa accepted by FSA
3.
4. A subset A of S of accepting states b a

5. An initial state aE S
A = (I, S, f, A, a) a

Exm,,ple
b
Transition diagram of FSA Yes
A = (I, s, f, A, a ) where Is the string ahhahha accepted by Fjn. b
I= {a, b}, s = { Oo,Ot,OJJ . A= { <J2}
a Go and f is given by table below a b
F
s/1 a b b
<Jo <Jo a,
<J1 <Jo <J2 a

I <J2 I <Jo <J2 I


b a
a No

b Q. Design FSA that accepts precisely those strings over {a , b}


that contain an odd number ofa's.
Two states
a OddA=(OA)
EvenA=(EA)
a . OA is accepted state
Incoming is i/p to a FSA, we will. end at Ifl·ther an accepM
.r,e EA is the initial state
or a non accepting state. The state of this fin~l state detefl1ll b b
whether the string is accepted by FSA. .
Let A(L S, f, A, a) be a FSA. '. be a str!A
I,.et a= x., .. .. .. Xn a
over I. If there exists states a 0......... On satisfying.

78 I lnsilhts on Discrete Structure


------------.:.___:--:------------
I
a

lnslat,ts on Discrete Structure 79


things. we say that the
--
.- ly the same . I . String(w)
SA accept prec1~e d 8 are equ1va ent tf Ac
lf two F uivalent. FSA A an A finite sequence of symbols taken from some alphabet is
automata are eq called string.
(A)= Ac (B)
Word or sentence is string of finite length of element of
Al~rithJn . .s whether a string over \a. b \ is symbols.
......... deternune
This algonuuu O100 is string from alphabet v = {0, 1}
accepted by FSA. . ( = o designation the null
of the smog n C_o ncatenation (vw): vw is string v, then string w.
Input: n., the \en . . gth
the smog. W": string w repeated n times
string)~s, Si · · · ·· Sn, . . ted
. , if the smog 1.s accep v+: all possible string using v.
QutpUt: • Accept . ted procedure fsa (s, n)
. ' if the string 15 not accep Empty string ( Xor E ore)
•Re.Ject
Zero occurance of symbols is nuU or empty string.
State: 'E'
F ori = 1 to n do · Length of string
begin The number of symbols present in the string.
If state= 'E' and S,= 'a' then W= 0100
State= ' O' lw1=4
If state =' O' and S; = •a ' then IEl=0
state ='E' 2.3.1 Language
End Natural Language is a method of combining words used to
If state = '0' then understand by a considerable community. Formal languages are
Return ("Accept") used to model natural languages and to communicate with
computers.
Else
Return ("Reject'") The 'rules of a natural language are very complex and
difficult to characterize completely.
End fsa
It is possible to specify completely the rules by which certain
~2.3~~1~.a~n~gu~a~g~e~an~d~G~r~ammar~~---------- fonnal languages are constructed.
Alpbabet or vocabulary · _, Definition
Of ysten..,-
Alphabet or vocabulary is a finite non empty set s
The set of all words or string including zero or v is denoted
It is denoted by I, or A or v byV•

V = {0, 1} is a binary alphabet Language is set of strings all of which are taken from v•
v= {a, b, ....z} is a set oflower case letter.
------=----=----==-==-=--------___,,,
l tnsilhtS
80 on Discrete Structure
Insights on Discrete Structure I 81
• bset of
A fonnal language over v is su
v•
A must include at least one non terminal symbol whereas
L~V• B can consists of any combination of non terminal and
V = {0, 1} terminal symbols.
Let,
V°= {}
V 1 ={0,l} N= { a, S)
V2=VUV T = {a, b}
= {0,l}U{0,l} P = {a - ba, a - as, s - bs, s - b}
= {00,01, 10,11} Then G = (N, T, P, CJ) is a grammar.

v• = Uf=oVi The language _generated by G, written L(G) consists of all


strings over T derivable from CJ
V-= Uf=t V;
For above grammar
y+ consist of all words formed _by concatenating a finite
number but not null.
a = ba = bba = bbas = bbab
The only derivations from CJ are
2.3.2 Grammar
a= ba...= b a
0
= b 0 as(~)
A way to determine the structure of a language is with a
grammar. In order to defjne a grammar, we need two kinds of = b"abm (n~, m2:l)
symbols: non terminal, used to represent given subsets of ~ . Thus, L(G) consists of the strings over {a, b} containing
language, and terminal, the final systems that occur in the strings of precisely one a that end with b.

I
the language. Types _of grammar (Chomsky hierarchy of grammar)
A grammar defining formal language I is a quadtruple 1. Unrestricted grammar (Type O)
G = (N, T, ~ S) If there is no restriction in the every production of the
grammar, it is called unrestricted grammar.
N = set of non terminal
Production rule
T = set of terminals
a-JJ
R = set of production Where,
S = start symbol ae(NuT)*
T is alphabet J}E(N UT)*
A grammar is a way to specify the set of all legal senten¢ It is recognized by Turing machine
of a language. 2.
Context Sensitive Grammar (Type t)
We _write G = (N, T, P, cr ). A production (A, BEP) ~ If every production is of the form
usually wntten A - B aA J} -. ayJ}
-
12~;;.;::-;;:::=:::=--:--------__,
82 I lnsllhts on Discrete Structure
Insights on Discrete Structure I 83
. the context of a and~ ) Starting symbol S
(we may rep lace A with rm
Grammar
a, ~E (NUT)* Mathematical model
AEN this grammar is recognized by Unrestricted type o ~ Turing machine
The language generated by
Context sensitive Linearly bounded
Linearly Bounded Automata.
grammar type 1
,~
. automata
3. Context Free Grammar (fype 2)
Push down
If the production is of the fonn Context free
1rrammar tvoe 2
~

- -- automata
A-+ y Regular . Finite
WbereAEN gra~r type 3
- Automata

yE(Nun•

Left side = single non tenninal


Right side = a word in one or more symbols.
BNF
N = {S, A, B}
An. alternative way to state or represent the productions
T = {a,b}
context free grammar is using
p = {S -+ aA, A-+ aAB, B -+ b, A-+ a}
I . Backus naur form and
Start symbol S. 2. Derivation tree
The language generated by this grammar is recognized by
Push down Automata. In BNF the non terminal symbols typically being with " <"
and end with">" the production S-+ Tis written S: :=T
4. Regular Grammar (fype 3)
If every production is of the form Production of the from S::=T 1, S::=T 2 •• • • •• S: := Tn may be
combined as S::=T,IT21........... Ta
A-+aor A-+aB or A-+ y
Grammar for integers
Where, A, B E N
<digit>:: = 0111213141516171819
a ET
<integer>: :=<signed integer>!< unsigned integer>
Left side = single non terminal <signed interger>::=+<digit>l-<unsigned integer>
Right side = either single terminal or terminal followed by a <unsigned integer>::=<digit>l<digit>< unsigned integer>
non terminal.
Derivation of-108
Recogniz.ed by Finite State Automata.
<integer>: :=<signed integer>: :=<unsigned integer>
N = {S, A}'
: := -<digit><unsigned integer> ::=-<digit><digit><unsigned
T= {a,b} integer>
P = {S-+ bS, S-+ aA, A - aS, A - bA, A-+ a, S-+ b} ::= -<digit><digit><digit
--::-7:'----::--:-:-----::-'-:-~------------------
84 I Insights on Discrete Structure Insights on Discrete Structure I 85
The terminal symbols are the input symbols {a, b}. The
::= -1 <digit><digit> states E and O become the non terminal symbols. The initial
::= -1 0<digit> state E becomes the starting symbol. The production
::= -108 corresponds to the directed edges.
If there is an edge labeled x from S to S' ,
2.4 Language and Automata --
. · a context free grammar and that a We write
15
A regular grammar
· ·th no production of the form A -+ ). is a S--+ xS'
context•free .grammar wi
In addition, if S is an accepting sta_te we includes the ·
context sensitive grammar. production
If every production is of the form S--+).
A --+ a or A --+ aB or A --+ ). In case
Where A, B eN , a e T* -{ ). } then G is also a regular E --+ aO, E --+ _bE, 0 --+ aE, 0 --+ bO
grammar. since O is accepting state we also include O --+ ).
Q. The grammar G defined by T = fa, b.c}, Then the grammar G = (N, T, P, E) with N = {O, E }, T = {a,
N ={ t1, A, B, C, D, E}, with productions b} and P consisting of above productions generate the
. t1 --+ aAB, t1--+ aB, A--+ aAC, .A-+ ac, B-+ DC, D-b, language L(G) which is the same as the set of string accepted
by above FSA.
CD --+ CE, CE --+ DE, DE --+ DC, Cc -+ Dec and starting I

symbol is contal sensitive


t1 _ Theorem
CD= CE= DE= DC (derivation ·of dC from CD) Let A be a FSA given as a transition diagram. Let er be the
3
The string a1,3c is in L(G) initial state. Let T be the set of input symbols and N be the set of
states.
aAB --+ aaACB = aaaCCDc = ·aaacDCc
Let P be the set of productions.
= aaaDCCc = aaaDCDcc = aaaDDCccc
= aaaDDDccc = aaabbbccc S--+ xS'

The string a1,3c3 is in L(G) If there is an edge labeled x from S to S' and
It can be show that s-s·
L(G) = {a°b c In= 1,2, .. ..... }
0 0
If S is an accepting state let G be the regular grammar.
Q. Write the regular grammar given by FSA !liven below G= (N,T,P,cr)
b Then set of strings accepted by A is equal to L(G) .
b
Reverse case
a Given a regular grammar G, we want to construct a FSA to
that L(G) is precisely the set of string accepted by A.

Insights on Discrete Structure I 87

86 I Insights on Discrete Structure


E.g.
i. vertex C has no outgo.
Consider the regular grammar defined by rng edge label a
ii. vertex F has no outgo· ·
mg at all
T= {a.b} iii. vertex C has two outg .
. . omg edges labeled b
N={o,c} This ts NDFA ( Non Dete . . .
nntnist1c Finite Automata)
With productions, 2.5 Non-deterministic Fin1't S
e late Automata
o -+ bcr, 0 -+ aC, C -+ bC, C -+ b and starting symbol 0 Definition:
The non terminal become state with CJ as the initial state. For NDFSA 'A' consists of
each production of the form a. A finite set I of input symbols.
S-+xS' b. A finite set S of states
we draw an edge from state s to S' and label it x. c. A next-state function f ti S .
S) rom xi mto P(S) (subset state
The productions: d. A subset A of S accepting states
CJ -+ bcr, o -+ aC, C -+ bC e. An initial state oES
give the graph as shown below We write A = ( L s, f, A, CJ )
b
b In DFSA, the next-state function takes us t .
defined state, whereas in NDFSA th o . a umquely
, e next-state function takes us
a to a set of states.
Example
l={a.b}
S= {CJ, C, F}
The production C -+ b is equivalent to two productions.
A= {F}
C -+ bF and F -+ >..
f
where F is an additional non terminal symbol. ~ a b
b
b 1: {c} { CJ}
C ~ {c, f}
. a F ~ ~

b
b

The production F -+ A. tells us that F should be an acceptin8


a
state.
This is not FSA

Insights on Discrete Structure I 89


88 I Insights on Discrete Structure
.........
The string a = bbabb is accepted because there is at least
path representing a that ends at an accepting state. Ollt
Q. ChangeNDFA toDFA
Q. Convert NDFSA to DFSA 0
b
b

I.
-s----.1 A B
{ cr} {c} { cr}
{C} { ~} {C, F}
{C, F} { ~} {C,F}
b
b
Q
a

I?

o'(qo,O) = o (qo, 0) = {qo}


, 1) = o(q0• 1)-
o'(qo, - { qo, qi} new state
0 {(q1, q2),0}= o(qi, O)U o(q2, 0)
g({cr },a)= {C}
= ~ U{q1, q2}
g({cr }, b)= { cr}
={q1, q2} old state
g({C},a)=~ o'({q1,q2}, l)=o(q1,l)Uo(q2, 1)
g ({C}, b) = E(C)UE(F) = {C, F} =$U~
g( {C, F}, a)=~ =~
0 . 0
g( {C, F}, b) = E(C)UE(F) = {C, F}
g( {F}, a)"=~
g({F}, b)=~

Equivalent OFA
90 I Insights on Discrete Structure
lnslpts on Discrete structure I 91

>
....
,f trings acCepted b11
.., the FSA show11
Q. Let L be the set ;S; that accepts the strings b b
below construct a
LR= {Xn •• •• xdx, ......Xn EL}
b
a

a
. above FSA and make
all arrows ID . 03 the starting
Reserve . tale The result 1s a NDFSA that g( {If,}, b)={lf,}
state and OJ the afceptmg s .
accepts L
R
Non Deterministic Finite State Automata
b A non-deterministic finite automaton is a generalization of a
a finite state automaton so that at each state there might be several
possible choices for the ..next state' instead ofjust one.
Convert NDFSA to DFSA
b
a
a

b
Change into DFSA .
E(o3).={o3}, E(o2) = {oi}, E(o,) = {01}
Transitions
(03, b, 03). (cr1, a, 01)
(03, b, 02) ( 01, ~ 02)

(o 1, b, cr3)
g( {(cr3}, a)= cl>
b
g( {(cr3}, b) = E(cr3)UE(o2) ={03, 02}
g( {(03, 02}, a)= cl>
g( {(o3, o2}, b)::;: E(o3)UE(o2)UE((o1) = {03, 02, oi} ~ Regular Expression and its Characteri~tics
g({(o3, 02; 01}, a)= E(o1)UE(o2)UE((o3) = {03, 02, 01}
. Regular expressions are useful for representing certain set of
g( {(03., 02,.01}, b) = E(o1)UE(o2)UE((o3) = {03, 02. oi} stri
ngs in an algebraic manner. Actually this describes the language
g({t}, a)={t} · accepted by finite state automata.
----------------------:-:=----:
92 I ln#ts,on ~ e .St~cture Insights on Discrete St~ctute I 93
al habet L are the strings ( 1O)* = Any number of copies of IO (including the null
2.
The regular expressions over anh Jat the following hold (}:
{) c u }sue string)
over the alphabet 2, U _' ' b..'... }
1/p symbols)
3. OUO l = The string O or the string OI.
consists of alphabet L - {a, ' mber of L is a regular
t IP and each me . 4. O(OU l )* = Any string not beginning with 0.
1. The empty se
5. (O* 1)* = Any string not ending with 0' .
·expression. . then their concatenation
If a and p are re gu
lar expressions
. 6. L* = {O. l }*= (0 + 1)*= { E,0,1,00,0I,10, l I..}
2. lar expression. O* + 1* = {E,0,00,000, ..... }
aP is also a regu . then their union ( a U P) is 1.
If a and p are regular .expressions = {e, 1, 11,111, . ..... } (can it give combination oniy either O or
3
· gular expressions. . . 1.)
also a re . th is the closure (iteration)
If a is a regular expressions en s O 8. O*l • = {E, 0, I, 01 , 001 , 0011, .}(zero never come after 1)
4.
• RE (a) is also RE.
a.• . If a is . . unless it follows from (I) 9. (01)* = {E, 01, 0101, 010101, ... .. . }
Nothing is a regular expression .
5. 1o. 0 1• + l O* =either single 0 followed by any number of l or
through(4). d ti vice versa.
haracterized as languages e med
Regular languages can be c 11. (O+l)*.00
b regular expressions. . . .
Y ed b . gular expression 1s given a A language is regular iff it is accepted by FSA.
Th l guage represent y re ).
e an .f ·s any regular expressions then Ll\l. is . There are three operations on language that the operators of ·
function .L, such that 1 a t regular expression represent.
the language represented by a.
L (IP)= IP, L(a) = {a}, for each a EL These operations are;
1. If a and p are regular expressions then L( ap) = _L (a). L(P) 1. Union:
2.
If O and p are regular expressions The union of two languages L and M de~oted by L + M is
3.
the set of strings that are in either L or M or both
Then
E.g.L= {001,10,111} andM= {E,001}
L(aUP) = L(a)UL (P)
Then,
4. If a is a regular expression
L + M = {E, l 0, 001 , 111 }
Then 2. Concatenation:
L (a*)= L(ci)*
The concatenation of language L and M is the set of strings
What are the strings specified by the regular expression?
that can be formed by taking any string in L and
,
Regular expression is language 1
generatyr •t
1 ge
nerates
. the
co~catenation it with any string i~ M and is denoted by L.M
set of all strings for finite automata. E.g. L= {001,.10,111},M= {E, 001}
(FSA, pumping lemma are langaage.recognizer.) 'Then,

l. 10* = A 'l' followed by any no. of O's including non zero. L.M = {001,10,111,001001,loP()l,) 11001}

94 I Insights ort:Discrete Structure Insights on Discrete Structure I 95


ldeene star) of language
The closure (or star or . .ql
3. d resents the set of those strings that .q2
Lis denoted by Lan -~p any number of strings from L
can
be formed by t~ng ·
t' s (i· e the same strmg may 1..
' Fl ql
A q2
'bl ·th repeta 10n · · U1:
. poss1 Y. wi
selected more than once
) and concatenating all of them.
· L• is the set of all the strings of O's and
0 -~
E.g. L = {O, l } then
Ml M2 M
is with E or A
M = (Q, I, o, q, F) where q is new state not in q.1or Q2
i.e. L = {O, l}
L*= {O, l}*= {A,0, l,01 , 10, 11 , 111, ... ) Q= Q1UQ2U{q} [SetofstatesofM]

The class of languages accepted by finite state automata (i.e. F = FI UF2 [Final states of M]
Transition function of M = o1U0iU {(q, E) - ((q, E) - q2)}
R.L.) is closed under.
Or,
1. Union
F1UF2U{s, e, s1),(S, e, s2)}
2. Concatenation
3. Kleene star 2. Concatenation :
4. Complementation Let Ml and M2 be NDFA. We construct a NDFA M such
5. Intersection that L(M)= L(M 1) - L(M2). The construction is shown in

-B the figure.

An automata with no final sets accepts or recognizes II>

Empty string
Sl
-+
Fl
~
-.0
s2
________ si° 7~
F2 __, F
Ml M2 M
M operates by simultaning M 1 for a while and then jumping
non-deterministically from a finite state of M 1 to the initial
state of M 2. Therefore M imitates M2 •
Formally, ·
Accepts the alphabet a
Let,
1. Union: .
· isri( Ml = (S 1, I, f1, St, f 1) or Q1, ,, Q1, F1) or'(Ql, L, ol, ql, Fl)
1

Let L 1 and L2 be languages accepted by non-deternun


automata Ml and M2 respectively. Let ·M1= (Qi, l, bi, ~ M2=(S'2, I, f 2, s2, F2) s 1and s2 are disjoint
F,) and M2= (Q2, I, Oi, Cu, F2). We assume that Qi _and~ L(M) = L(M 1).L(M2)
are disjoint sets. We construct NDFSA M that acce_ M = (S, I, f, cr , F)
L(M1)UL(M2) as follows
Insights on Discrete Structure I 97
96 I lnsi&hts on Discrete Structure

>
_ S' US' 2=union of MI and M2
Set of states ofM -S-
- I · Technique to identify the class of language for finite
- final states ofM2 (F2) automata is pumping lemma.
Final states (F)- . fMl and M2 plus (F 1X{e}X{s2})
Transition S = Umon ° Show that the language

. F = F iUF2U {(Fi. c)-+ S2} L = {a"b" n > 0} is not regular


wEL
Kl star·
eene · truct a NDF A M such that L(M) w = ai>b"
L t M be a NDF A we cons
=eL(~1t. The construction is show below. According to the pumping lemma
x=aq, y=a', z=ap-{q +r>i,p
Since,
0
Sl · xyE L
-+ 0
Sl Now,
Fl Fl
xy2z
M = aq(a')2(ap-(q +'>\,'J j '

= aqa2rap-{q +r>i,i>
L(M)=L(M1) = aP +'bP L
States of M = states of M I plus s' 1
Since xy2z is not the from a~ therefore xy2z EL. It is
Final states of M:= Final states ofM1 pl~ s' 1 . contradiction. Hence L is not regular.
Transition of M = Transition of M, plus ~FX {e}} X {s,})
Closure properties of Regular Language
F = F1UF2U{(F, e, S1)}
If L and M be regular language. Then following languages
Pumping lemma (fheorein) for Regular Language . are all regular.
.
Pumping lemma is a powerful technique for sh owmg
· certain l. Union : L U M, L + M
language to be non-regular. 2. Intersection: L nM
Statement 3. Complement : N, L and M, i =I,* \L
. t constant n 4. Difference : L\M = L n M
. Let L be a regular language. Then there ext a . w\
(which depend on L) such that for every string win L, such tbat I 5. Reversal LR= WR :wEL
~n. 6. Closure: L*
We can break w into three sub strings 7.
Concatenation : L.M
I. y-:/=E 8.
Homomorphism
2. lxyl~n h(L) = {h(w) I we L, his homomorphism}
3. For all i~, string xy'z is also in L
Insights on Discrete Structure I 99
98 1lnsi&hts on Discrete Structure
9.
Inverse homomorphism a is a homomorphism)
h·'(L) == {wE \ b(w)L, h:1: - J. Design FSA transition diagram that accepts the given set of
string over {a, b}. {2076 Baisakh, Back}
homomorphism
h:r· - 0 • ( alphabet L . 0 ) ,.• Which starts with ab and ends with baa
Solution:
w:a,a2••·····;····•anEL* FSA which starts with ab and ends with ba
h(w) == h(a,) b(a2) .........h(an)
b(L) == {h(w)\wEL}
Example
\etb:{O,l }* - {a, b} • be defined by
h(O)== a b and b( l )== E
now,
h(OOl l)==abab
b(L(lO*l))== L((ab*))

ii. Where every b is followed by a


a a

2. How do you define a Finite State Automation (FSA)?


Design a finite state automata that accepts precisely
those strings over {a, b} that end with substring aa.
· Your design should include the proper definition of
the finite state automation, transition table and the
transition diagram. /2073 Bhadra}

Insights on Discrete Structure I 101


100 I Insights on Disaete Structure

>
.....

a a b

b a
a

b
b
b
a
es the string having the
hat generat
Write a grammar t
3. 4. Design a Grammar to generate Palindrome for Binary
given proP.erlY• .
i b,1 ending with ba Numbtrr. Consider the right linear Grammar G = {N, T, P,
a. String over ia, • /2073 Bhadra/ SJ, where N = set of non-terminal = {A, B, SJ, T = Set ·of
1. b I starting with a Terminal = {a, b, c}, and P consists of the following rules:
b String over I a, 'I
• ding with ba
b} {S - t abAI bbB/ a, A - aA/ bB/b, B - BaB/aaaA).
a. String over {a, en G == (N, T, R. S) Construct the NDFA equivalent to the given grammar.
Let the grammar G be
f 1076 Baisakh, Back/
N =={S, A, B}
Solution:
::{~~}aS\bA, A-+ aB\bA, B-+ aS\bA} Grammar to generate palindrome for binary number
G = (N, T, R, S)
starting symbol is S
N = Set of non - terminal = {S}
b T = Set of terminal {O, 1}
a R = Set of Production rule= {S - OSOi 1S1 le: I 1 IO}
S=StartSymbol = {S}
b
5. Differentiate between a.Finite State Machine and a Finite
. State Automation. Design a Finite State Automata that
accepts precisely those string over {a, b} that contains an
a even no. of a's. Your design should indude the proper
definition of the Finite State Automata, transition table and
the transition diagram. "(072 Ashwin/
String over {a, b} starting with a Hints:
b.
Let the grammar G be O == (N, T, R, S) b
b
N={S, A, B}
T={a,b} a
R={S - t aA\bB, A-+ aA\bA, B ~ aB\bB}
Starting symbol is S a

102 I Insights on Dlsaete Structure _,___ Insights on Discrete-Structure I 103.


.......-
. . State Automata. Desig11 g Table:1
. . .:c Finite . h .
'Ill Determinis.. ts precisely t ose stn11"' Fig( l) and table 1 are transition diagram and transition table
D ~ne r,on- hat accep . , 11'
6. F~ ·te State Automata t . two consecutive a s. respectively for a finite state automata that accepts precisely
ini b} that do not contain /071 MaghJ
over {a, those strings over {a, b} that do not contain two consecutive
a's.
SoI udon: .
.
ves a mac
hine multiple options for its
t'. 7. Construct the regular grammar to generate integers. Your
. . . fini·te state automata, ,or each
Non detenninisnc gt rm.inisnc construction should include the proper definitions of the ·
• moves.
{n a non dete
be zero, one,
1 . .
two or more transitions grammar, which includes properly defined non-terminal
state there can . tar symbol. symbols, terminal symbols, production· rules and starting
corresponding to a particu symbol /071 Maghj
i e.in put-state pair. . . takes us to a uniquely Solution:
· t function .
In DFSA, the next-sta ~ NDFSA, the next state funcllon
• defined state, whereas m
• Grammar is a way to detennine or specify the structure or set
of sentences of a language.
takes us to a set ~f ~tates: tate automata is a 5 tuple (I, S, f,
A.non-dete
nnimsnc finite s • A grammar defining formal language L is a quadtuple
G = (N, T , P, S)
0 A) where
1
' I is a finite set of input symbo s N . is set of non terminal symbols, used to represent given
subsets of the language.
- S is a finite set of states . . . f on function from SXI
F is a next state function or trans1 l • Non terminals can be placed.

to 2
5
• Non terminals (or syntactic symbols) are replaced by groups
oftenninal symbols according to the production rules.
_ 0 E s is an initial state
A£,S is accepting states. T is set of terminal symbols

Transition diagram: • Terminal symbols are literal symbols which may appear in
a the outputs of production rule or may occur in the outputs of
b
production rule or may occur in the strings of the language.
a
a
\..---~0
b
b
The lexical elements terminals and non-terminals of a
particular grammar are two disjoint sets.
P is set of production rule
. .
-
• A grammar is defined by production rule th~t specify which
Transition table: symbols may replace with other symbol to generate string.
a b
s/1
S2 S1 • A symbol substitution can be recursively perfonned to
-+S1
generate a symbol sequence.
S3 S1
S2
S3
-
• Each production rule has a head on left hand side which
S.3 S3 -
consists of the string that may be replaced, and a body, or

Insights on Discrete Structure I 105 I


I Insights on Dlsaete
l04 Structure
J
b
right-hand side, which consis~ of a sE. The. type of graJntnar
is distinguished by the properties of production rule. S. N. Finite State Machine ,.__~' :=-.- . - - - -
In regular grammar, every production is of the fonn. 2 A fiqite state mach · - - Finite State Auto_ _ _ _
· • ine M A fi mata
CODSJStS of tnite State -
A -+ a or A -+ aB or A -+ A con . automata A
a. Finite set of · s1st of
input symbols · .
Where A, BEN (I) a. Finite set of .
(I) - input symboJ
AET b Finite set of s
i.e. In left side there is single terminal ?~bols (0) output:· finite set of states (s)
In right side there may be either single lenninal or terminal c. Fm1te set of states (s) · next state function (f)
followed by a non-terminal or just null string. d. Next state function (f) d. accepting state A i b
ofS s su set
Now, to construct the regular grammar to generate integers, e. Output function (g) ·
f. An initial state crE s e. an initial state crEs
N= {S}
M = (I, 0, S, f, .I?, cr) A == (I, S, F, A, cr )
T= {0, 1,2,3,4,5,6, 7,8,9}
3. ~xample: FSM that •....➔.
P = {s-+ 0 Ill 213141 5161 71 81 91 0sllsl 2sl 3sl 4sl 5sl 6sl 7 . .,..., ,orms Example· FSA
se~al adder that takes · . that accepts
8sl9s} .. paus of bits as input precisely those strings
Starting symbol is S. . over {a, b} that -contain
As mentioned earlier, N is set of tenninal symbol, T is set of an odd number of a' s.
· non tenninal symbols, P is production rule and s is start
symbol. The grammar G = (N, T, P, S) with above values ii
a
the regular grammar that ·generate integers.
8. Differentiate between finiJe state machines and finiJe std
Transition diagram b
automata. Design a finite state automata that ace~
precisely those strings over {a, b} that accepts precistl! The transition diagram is a di .
those strings over {a, b} that contain an odd number ofb'1 states. The · ·ti . . . graph. The vertices are the
Your design should include the proper definition of t1J iru a 1 state is mdicated by arrow. .
finite-state automation, transition table and the transidol Here, the initial stat . 1
inputinga or b e is s . If we are in state s I and
diagram. /071 BhoJni
rounded sta . we move to s2 states. The douhie
Solution: state. te is final or accepting s~te. S2 is accepting
S. N. Finite State Machine Finite State Automata
I. A finite state machine is an A finite state . automata .t Transition table:

- -s.
,__
abstract inodel of a machine similar to finite state macbl' s/1 I
a b
with a primitive internal but with no output and ou~
I--
memory. function but it has accepriD/ S2 S2
S2
or final states. S2 s.

106 f lnslpts on Discrete Structure

b
........

9.
Consider the regular grammar G == !!''
T, P, a) ~here N~
set of non-terminals == {<1, A , BJ, T - set of terminals :::: {a,
Where p is an additional non tennma
. 1 symbol.-

b} with productions <1 -+ aA, <1 -+ bB, A -+ a, B -+ a Q1r4


starting symbol a •
Construct non-determitlistic finite state auto,nlllt
O
equivalent to the above given regula~ grammar and conve"
this into equivalent deterministic finite state automata. 1071
Bhadra] Ttie production F --+ ,_ tell us that I h Id b .
state. . s ou e an acceptmg
Solution:
Here, Transition table
G=(N,T,P,CJ) s/1 a b
-
N = set ofnon-tenninals = { CJ, A, B} a {A} {B}
T = set of tenninals {a, b} A {F} {0}
P = production rules B {F} {0}
=={ CJ --+ aA, CJ -+ bB, A -+ a, B -+ b} Now, convert NDFSA to DFSA
CJ == starting symbol s/1 a b
The non -tenninals become starts with CJ as the initial state {a} {A} {B}
For each productions of the fonn {A} {F} {0}
s--+ xs' {B} {F} {0}
we draw an edge from state s to s' and label it x. {F} {0} {0}
here, the ·productions are
a --+ aA, a -+ bB
Give the graph as shown below

The production A-a is equivalent to two productions


A-+aFandF-+A
Similarly production B-a is equivalent to two productions
B -+ aF and F -+ ,._

108 I lnsipts on -Discrete Structure Insights on Discrete Structure 1109

>
-----:::R~e---cu~r=r=e=n:ce~R~e~la;.ti~-o;;n;--......._
. Def..iru"tion of Sequences
- -- Example

1.
Let {a,J be a sequence that satisfier; th ·
. ethat
a,, = a,,.ra,,.1 fior n -- 2,3,4 and suppose
what are a1 and aj?
recurrence
a == J relation.
-
and a1 - 5
3.1 Recursive . '
From the recurrence relation.
n be defined by givmg a gene~al fonnula for
•. A sequenc~
th _ca a few o f 1·ts terms.
by wntmg · An alternative approach
. is 8n = 8n- l - 80-2
n term the sequence by finding a relationship among its terms.
tts represent
to a2 =a 1-ao = 5-3 = 2
Such relations are referred as recurrences. a3=ara 1 = 2-5=-3
Recursively defined sequences are often referred to as
Similarly a., as and also each successive tenns Th seq
recurrence relations. forms in such a way is 3,5,2,-3, ..... . e uence
A recurrence re Iauon
..: for the sequence {a.i} is. an equation J.
th t presses a.i m Determine whet?er the sequence {a,J is a solution of the
. terms o f one or more of the previous tenns . of recu"ence relation a,. = 2a,,.,-o,._1 fior n = 2 3 ~ ....,,_
thea sequence
ex namely ao, a1, a2,...... 8n- • for all integers n with n~ , ,.,, ••• "'· ,,,;;., 'I! a,,
where 1lo is a non-negative integer. . .
= Jn for every non negative integer n. Answer the· sa1t1e
question where a,, =2" and where a,.= 5.
A sequence 1s . called a solution. of a recurrence relation if Suppose that a.i = 3n for every n. therefore n::'.'2, 2a,,. -a,,.
their terms satisfy the recurrence relation. 1 2
= 2(3(n - I) - 3(n -2))
Example
= 6n - 6 - 3n + 6
Consider the following instructions for generating , =3n
sequence
=a.i
J. Start will, 3
2• Since {a,,}, where a,,= 3n, is a solution of the recurrence
relation.
Given any term, add 3 io get the n.e xt term.
The term of sequence obtained is Suppose a,,= 2° for every n. note ao == 2°- I
3 ,6, 9, 12, 15, 18,..... And a1 = 2' = 2 and a2 = 22 = 4
Ifwe denote the sequence as a1, a2, .. .. 2a.i..1 - an-2, (n = 2)
81 = 3 ············· (l) ::::: 2a1-ao
Instruction (2) can be rephrased as
= 3 t a 2, we see that {a
== 2.2-I },

a.i= au- + 3
1 n~ ........... {A)
0

4. Where au = 2" is not a solution of recurrence relation. au= 5


By using a 1 and a.i, we can compute any tenn in the
sequence. A custo,ner deposits 10,000 in a bank and /r.e gets 11%
illterest per annual and the interest amount is accumulated
Equation (A) is an example of recurrence relation (1)
every Year. Find the recurrence relation to compute total .
a11rou111 Clisto,ner receive after JO year. And also cakulate
01110
unr that customer receive after 30 years.

-------------~--=:::-:-:--:::==--,;,11
lnslshts on Dfsaete S~ure I 111
Po::: 10,000
Solving linear homogeneous recurrence relation
Interest == 11 % ~ethod of characteristic equation
P1 == Po+ 0.11 •po We know that the line~ homogeneous recurrence relation of
== 1.1 lPo degree k with constant coefficients is of the fonn.
== 11100 3n = C13n-1+ C23n-2 + .. . .... + Ck3n-k
P2 == Pt •0.11+ Pt Let an= r° is the solution of thfa equation then
::: 1.11 Po • 0.11 + Po • 1.11 2
r"== c,r°-l + C2r"° + ...... + Ck3n-k
== 1.11pO(0.l l + 1) .
Dividing both by r""k
= (1.1 l)Po *1.11
. :::: ( 1.11 )2p0 I== c,I·' + eit·2 + ... ..+c,.
rk-c,rk•'-c2r1'·2- .....-ck = 0
3
p 3 :::: 1.l lp2 = (1,11) Po
Pn== (1,l l)Pn--t == (1.l l)"J>o This is the characteristic equation of degree k of the
Pn= (1.1 It 10,000. recurrence relation.
3.2 Solution of Linear Recurrence Relations Let us consider the liner homogeneous recurrence refations
of degree 2.
A linear homogeneous recurrence relation of degree k with
constant coefficient is a recurrence relation of the form i.e.
a,,= c,a...,+ Cia...2
a,,= Cta...t+ c2a...2+ •·············· · · · + Ckllo-k ..
Where c1, c2, ....Ck are real numbers and ck'/= 0. Its characteristic equation is of the form
The recurrence relation in the definition is linear since R.H.S r2-c,r-c2= 0
is a sum of multiples of the previous terms of the sequence. The roots of this equation can be
The recurrence relation is homogeneous since no tenn occur 1. Distinct root~ say r 1 and r2 (i.e. r 1 #; r2)
that are not multiple of the a;s.
th
1!' roots are distinct then
{a.i} is the solution of the given
The degree is k because a,, is expressed in terms of e hnear homogeneous recurrence relation if and only if a.i is of
previous k term of the sequence. the fonn

If f(n) -:;. 0 for the recurrence relation a.i= a1r,°+ a2r/ where a, and a 2 are constant
2.
Repeated roots, say r, (i.e. r1=r2=r,)
.a..= Cta...1+ c2a...2+ ....+ Ckllo-k+ f(n)
If roots are repeated root, say r0 then {a.i} is the solution of
Then it ~s called non-homogeneous recurrence relation.
~e given linear homogeneous recurrence relation if and only
If f(n) =0 then it is called linear homogeneous recurrence if 8n is of the form ·
relation.

lU I lnsiprts on Discrete Structure Insights on Discrete Structure I 113


I-fence the solution to the recurrence relation and initial
eorem: - 2
se that r -c, r-c2== 0 has conditions is the sequence {~ } with a0 == 3.2"-(-l )"
Th d be real numbers suppo e {a } is a solution of Find the explicit formula for the fibonacci numbers.
Let c, an C2 the sequenc n n n"
.
distmct roo s ,t r and r2, then 'ff
+c a , t an = a 1r 1 + a2r2 aor
. .n.::: OR
two \ation an::::: c,a.,..1 2 0 · - t To find a 1 and a2 tnthal
the recurrence re d are constan . Find the solution of recurrence relation offtbonacci series.
0, 1, 2 , .. ... where a, an a2 ao=O '
condition is used. . if recurrence relaJion a,= 1
What is the solution o - 7
J. 2 with a,= 2 and a, - an = an., +an.2
a,. = a,.., + a,..2
n The characteristic equation ~f ao == a,,. 1+a,,.2is
Let au= r . _ a + 2an.2
. the equatton an - n- 1 r" = r"° I+r""2
Substituting m
· (since assume 3n = r" then rn_== r"" 1+r""2)
w~ get,
t' = t'"' + 2r"°2............ (i) r"/~ 2= r""l /r"-2-+r"°2/r""2
.) b t'"2 we get r2-r-l =0
Dividing equation (1 y '
r2-r-2=0 + t±J(-1)2-4(1)( -1)
r=
r2 _ (2 _ 1)r - 2 = 0
1±./S
r2 _ 2r + r - 2 = 0 r=-2-
r(r - 2) + l(r - 2) = 0 1+./S
r,=-2-
( 2Xr + I)= O · }·
r- . d = -1 Hence the sequence {an ts a 1-./S
Its roots are r = 2 an r ·. . r2=-2-
solution to the recurrence relation iff
Then fibonacci numbers are given by
au= a 1r 1D+ a2r2 R au= a,r,"+ a 2ri°
au= a 12"+ a 2(-I)"
· a • From 101
and • ·t·1al conditions it = «1((1+-Js)/ 2)"+ a 2((1+-v5)/2)"
For some constants <l1 2
follows that, For some constants a 1 and a2 , using ao= 0 and a,= I
Whenn=0,3o=O
ao=a, +a2 =2
a1= a12+ a2 (-1)
ao= a,+ a2
a,z --<12
7= a12+ a2 (-1)
When n = 1, a, = 1
i.e. <l1+ a2 = 2 ........... (ii)
2 a,- a2 = 7 ................(iii) a,= a, ((l+v'S)/2) 1+ a2((1~)/2)1
1
Solving these two equation = ·a2 ((l+v'S)/2) + a 2((1~)/2)
a 1= 3 and a2 =- 1 = «2 (-1/2-v'S/2 + 1/2-../s/2)
~2 (-2v'S/2)
l14 I lnsi&hts on Discrete Structure -Insights on Discrete Structure I 115
........
'f}teoreJJt :
a 2=-t/..fs Let c,, c2,•.. ....ck be real numbers,
suppose that the
C
teristics equation
chara
a,= 11../S - r.:5 ({ 1+../5)12)"+ (-I /../5 )(( t-v'S)/2)" . . I
/-c/- ..... -Ck= 0
Hence, an- 1/v::i •
What is the solution of recurrence re/anon bas t distinct
3. . roots r,, r2 ........... rk with multiplicat1·0 n m1, m.2,
. with a,= 3 and a,= 7 .. lllt respectively so that m; 2:1 for 1,2, ....t and m +m + +m
a,. = 6a,,_1 + 9a,._i (113,. . . . . . I 2 . •. k
c:: k. Then a sequence {Sn} 1s a solution of the recurrence relation
Solution,
3n = 6a,,_ 1 + 9an-2 an= c,an-,+c2an-2+ ......+ck3n-k iff
Let an= r" 3n:= ( 01,0+ « 1,1n+.......... + 0 1, m1 .1nml-l)r1"+
We get, (a2 •0+ a2.,n+ .......... + a2.m2.,nm2- 1)r2"+....
r"= 6r"" 1 + 9rn-2................. (I)
..... + ( Ot,o+ 0t.,n+ .......... + <lt.m1-1nrm-l)ri"
Dividing equation ( l) by rn-2' we get
For n = 0, l , 2, .... Where <I;.j are constants for 1~ i ~ t and o
r2-6r-9 = 0 :'.;:j ~mi- I
Solving,
Suppose that roots of the characteristics equation of a linear
We get.... homogeneous recurrence relation are 2, 2, 2, 5, 5 and 9 (that is
there are three roots, the root 2 with multiplicity two three, the root
Theorem: . 5 with multiplicity two and the root 9 with multipllcity one.
Let c, and c2 be real number with ci;eO. Sup~ose that r2-c,r-c2 What is the form of general solution?
= o bas only one root r0. A ~equence {Sn} is a solution of recurrence
0 (a,.o+ a,., n+ a,,2 n2)2°+( a 2•0+ a 2•1n)5°+ a3.09°
relation 3n = c,a,,.,+eia..-2 iff an= a,ro + a2nro , for n = 0,1 ,2,....
0

Where a 1 and a 2 are constant. I. "• = 6a._r9a,._z with a,= 1, a1 = 6

Theorem: Find the solution ofgiven recu"ence relation. .


Solution:
Let C1, C2, . • .• .... Ck be real numbers. Suppose that tbe l .

characteristic equation. a.,== 63n- 1 - 9an-2


. r"-c, r"·' .......-c1c= 0 Let ao= r", we get
1
has k distinct roots r 1, r2, ...... r1c then sequence {an} is a r° == 6~ - 9rn-2, we get,
solution of recurrence relation. r2== 6r - 9

an = c,(ao-,) + eian-2+ ...... +c1can-1ciff r2-6r + 9 == O ................(1)

3n = a,ri°+ a 2ri°+ ..... + (lt.:r1c for n = 0, 1,2.... where a,. al


0
This is a characteristic equation,
a 3,.......•• Cltc are constants. Solving the equation ( l)
r:::::: 3, 3

116 I Insights on Dtsaete Structure Insights on Dlsaete Structure I 117


Hence, Solving equation ( 1),(2) and (3)
, , we get
a,, = a 13n+ a2 nJ for some constants, applying initial
0
a, = 1. a2=- I. a3== 2 _
condition. Hence the solution is given by
Here, ao= 1 a,,= l-2n + 2.3"
ao=a, J. Find the solution to the recu
. . .. , rrence re/ati
a 1= 1 Ja,,.1 - a,,.J with m1t;a/ conditio
- 2 a,. == -3a,,_, -
ns ao == 1 a on
Here a 1 = 6 The characteristic of this recurre ~ , - • and a2 == -1
_J -2 nee relation is
a,= a 13+ a23 r + 3r + 3r + 1 = 0
6 = 3+ a23 (r+J )3 =o
a2 = 1 r1= r2= r3=- I i.e. there is a single _
Hence the solution is a,,= 3"+ n3" three of characteristic equation. root r - -I of multiplicity

2. Find the solution. to the recu"ence relation a,, = 6a,,.1 • The solution is given by,
11a.2 + 6a.J a,, = ( a,.o+ a1.1n+ a u n2)(-I ) 0
With the inituzl conditions a,= 2, a,= 5 and a2 = 15. = (a,.o(-J Y + a 1,1n(-J) + ai,2n2(-l)n
0

Solution: To find the constants a10 a1 1 d


.· · · • an a 1.2 use the initial
cond 1t1on. This gives
The characteristic equation is given by
ao == l=a1,0 ... ............ . ..... . ... ...........(l)
r3 - 6~ + llr- 6 = 0
or, r3- r2-sr2+ Sr + 6r-6 = 0 a, = -2 = a 1.o(-l) + a 1,1(-J ) + a,.2(-I)
a1 = -2 = - a 1.0- o 1. 1- 0,,2 ........................(2)
or, r2(r - 1)- Sr(r- 1) + 6(r - I) = 0
or, (r- l)(r2- Sr+ 6) = 0 a2== -1 = (a1.o(-I/ + a 1,12(-l)2+ a1,122(-1)2
or, (r - l)(r2- 3r- 2r + 6) = 0 a2 = -I = a1 ,o + 2aI.I + 4a 1,1.........................(3)
or, (r - I) [r(r - 3) - 2(r - 3)] =0 Solving (1),(2) and (3), we get,
or, (r - l)(r - 2)(r - 3) = 0 a,.o'== I, 01.1 = 3, 01,1=-2
r1 = l , t2 = 2, r3 = 3. Hence, the solution is given by,
The solution is then given by 2n= 1(-I)"+ 3n(-l)"+ (-2)n 2(-I)°
a,,= o,. l 0 + 02.2°+ a3.3° 2n= (I + 3n - 2n2)(-I)"
For some constants tt1• a 2, and a 3 !ower of Hanoi Puzzle
Finding o 1• a2and o3 using initial conditions Ther ·
Peg, With ~~ 3 pegs aqd n circular disks of increasing on one
ao = 2= 01+ 02+ a3.............(1) fransferr d e largest on the bottom. These disks are to be
a1 = 5= a1+ 02.2+ 03.3 ........(2) that larg:r ~~e a~ a time onto the another peg, with the provision
a2 = 15= o,+ 02.4+ 03.9......(3) isk 1s not allowed to place on a smaller disk. The

· 118 I Insights on Discrete Structure


. . the number of moves necessary for tL We. have to verify this form u1a for h d. ,
problem 1s to· detemune ,, venfied by mathematical induCt·ion. " an it can be eaSI.1y
transfer. Since ho= 0, it holds for n == o
Solution: ber of moves required to transfer n disL Assume that it holds for n. we then sho .
h b thenUm
Letne Wh '- · replaced by n + J w It holds with n
We verify that ho= 0, h1 = l and h2 = 3. e ave to find a
i.e. hn + 1 = 2hn + I
recurrence relation that is satisfied by hn.
= 2(2"-I) + J
= 2" + 1-1
Since it also holds for n + I he h
• ' nee t e fonnula is verified.
Peg2 Peg3 3.3 Solution of Nonlinear Recurrence Relations
Peg I
To solve the non-homogen eous recurre .
To transfer n disks to another peg, we first transfer the top o- constant coefficient, we need t . nee relation with
o so1ve its .
1 disks to a peg, tranSfer the largest disk to the vacant pe1 homogeneous equation and to find . associated liner
. h a particular sol f
and then tranSfer all n-1 disks to the peg, which now contam given non- omogeneous equation. . u 100 for the
the largest disk, thi~ h0 satisfies hn = 2hn-1 + 1(n:2'.: 1) where ~= A recurrence relation of the form
0
3n= c,a,,.., + c2a,,..2+ ....+ cka...i,+ F(n)
This is a recurrence relation of order 1 with const31i
coefficients, but it is not homogeneous, because of th: •
Where c ,,· c 2, • •• ·•• ck are real numbers . ·
not identically zero d di and F(n) 1s a function
presence of the quantity. h epen ng only on . r
omogeneous recurrence relati Th n is mear non-
1. To fmd h., we iterate the above equation. on. e recurrence relation

' h., = 211.r, + 1


= 2(2hn-2+ 1) + 1
= 22ho-2 + 1
=22(2hn-3 + 1) + 2 + 1
a.i= Ci8n-1+Cia,,..2+ ..... C~
is called the associ ted h
For example,

l. 3n::: a,,_ I + 2°
a omogeneous recurrence relation.

2· 3n== 8n-1+a,,..2+n2+n + I
= 2n-1(2ho+ 1) + 2n-2+ .... + 22 + 2 + 1
3· 3n = 33n-1+n3"
= 2n-l + 2n-2+ .. ... + z2 + 2 + 1
4
t(zn-1) . a(rn-1) · 8n = lln-,+2n.2+3n-3+n
= --------- ( smce Sn= ~~)
2-1 r-1
These are exam l
relation w .th
.
P es of lmear non-homogeneous recurrence
= 2°-1 h0rnogeneo• constant coeffic1ents . corresponding associated linear
Therefore, the no. hn are the partial sums of the georoetJI us recurrence relation are
sequence 1,2,22, ••• 2° and hence satisfy. l . 8n == lln-1
zn-1 2. a.i::: -n-1
SI +lln-2
2 1
_ _ _ _h_u_=~-_-_=_2_"-_1_=_2n-_•- - - - - - - -~
120 I Insights on Discrete Structure r Insights on Discrete Structure I Ul
..
for f(n) = 3"
3. · an= 3an-l Because s = 3 is a root with mult' 1..
4. an = an.1+an.2+an-3 .l". 2n• Ip ic1ty 2 part"
has the 1orm Pon 3 1f f(n) == 3 11 ' · icufar solution

Theorem: For f(n) = n3"


If {a Cpl} is a particular solution o~ t_he non-homogeneo11s The form is n\p,n + Po)3" if f(n) == n3"
n . •h stant coetllc1ents.
liner recurrence relation wit con For f(n) = n 22"
ao = C1an-1+C2an.2+ .....+ckan-k+ f(n)
(pl +a (h>} whe (h) The form is (p2n2+ p,n + Po)2" if f(n) == n22"
Then every solution is of the tiorm { an n . re a,, is
. . of the assoc1a
. ted homogeneous recurrence relation. For f(n) = (n 2 + 1)3 8
a solutton 2 2
The form is n (p2n +p 1n + Po)3" 1·f fi( ) _
an= C1an-1+C23n-2+ · · ... +ckan-k n -(n2 + 1)3"
2. Find all solutions of the recurre .,
,· Theorem: . nee re,ation a - 3
what 1s the solution with a,== 3 ? " - a,,_,+ 2n.
Suppose {an} satisfies the linear recurrence relation.
Solution,
ao= C18n-1+C28n-2+ ....+C1t8n.1c+ f(n) The associated linear homogeneou . .
s equation 1s ¾ = 3~
Where c,, c2,••··•c1t are real numbers and Its solution are a,,<h>= a3° --n-1
11
f(n) = (b1n + b,.
1
+ ...... + b1n + bo)s"
10 • Where a is constant
Where ho, b1.••··· ......bt and s are real numbers. ~en s i~ oo Now, finding particular solution
a root of the characteristics equation of the associated lmeai
homogeneous recurrence relation there is a particular solution of ftn) = 2n is a polynomial of degree one
the fonn. Comparing with ftn)= p(n) s"
<Ptnt + p._1nt-1 + .....+p,n + Pt)s■ we get, s = 1
When s is a root of this characteristic equation and itl The root of the characteristic equation is 3
multiplicity is m, there is a particular solution is the fonn Here s is not th f h . .
'. .. e root o c aractenstic equation of the
n•(ptnt+ Pt-1Dt-J + ••••• + P1D + Po)s• associated hnear horn ·
. · ogeneous recurrence relation, there is a
J. · What form does a particular solution of the linear no• particular solution of the fonn
homogeneous recu"ence relation a,,= 6a,,.r9a,,.1+f(n). CPo + p,n + .. ... + p,.,n'·' + Ptn')s"
. .

have when f(n) = 3" = <Po+ p,n)s"


f(n) =n3" == CPo+ p 1n)
f(n)=n 1 r New, equation an= 33n-1 + 2n becomes
1
f(n) =(n + 1)3" <Po+ Pin)== 3(po+ p,(n - l)) + 2n
Soludon or, (Po+ Pin)= 3po+ 3p1n - 3p 1+ 2n
The associated linear homogeneous recurrence relation is.'. or, n(p, - 3p, - 2) = 2po - 3p,
= 63n-1 - 93n-2, Its characteristics equatio,i, r2 - 6r + 9 == (r · J or, n(-2p1 - 2) = 2po - 3p1
= 0 has a single root 3, of multiplicity two.
tnsfih&~rrt>f~ctt!te'St~~' lJ tt
-·~ .
(2 + 2) + 2po - 3p1 = 0
or, n Pt d . a solution if and only if 2 + 2p1 ::. 0
It follows that en + ts
and 2po-3P1 = O
Let a,, be the sum of the first n positive integer so that
a.=== t: =t k
a,, satisfies the linear non-homogeneous recurrence relation
a,,= a,,.. 1+n ............ (I)
7
•.• p I = -1 ' Po= -3/2
an(JI)= - n- 3/2 The associated linear homogeneous recurrence relation are
3n = 3n(JI) + lln(h) given by
= _n _ 3/2 + a.3" a,.<h> = c( 1 I f = c,
To find solution with a,= 3 Where c is constant

n=l,a,=3 Here,
3= _ 1 - 3/2 + 3a We have,

6=-2-3+6o. f(n) = n
a= 11/6
Comparing with f(n) = p(n)s"
an= -n-3/2 + (11/6)3" · s=l
Filtd the sol11dor,s of rec11n-ence relaJion a,. = Sa,,.,- 6a.1 + Here, s is the root of characteristic equation. The particular
3. solution is in the fonn
1'
n(p,n + Po)
Solution,
The solution of its associated homogeneous recurrence = p1n2 + Poll (here m = l)
relation Now,
I
· an= Sa,..1 - 6a...2 Equation ( 1) becomes
Here, p,n2 + Poll= p,(n - 1)2+ Po(n-1) + n
f{n) = 7n Simplifying we see,
Comparing with f{n) = p(n) s" n(2p, - 1) + (po- p 1) = 0 which means
s=7 . 2p,-l =Oandp0-p 1 =0
• ·
Here s is not the root of characteristic equation,
there 1s
particular solution in the fonn Pt= Po= 1/2
Po=7D Hence,
2
Now, equation an= 5an-1 - 63n-2 + 7" becomes an<P>= n /2 + n/2 = n(n + l )/2 is a particular solution
Po7D= 5.Po7o-1 _6.Po7°"2+ 7n 3n = 3n(p) + fln(h)
Po=49/20 Bn=n(n + 1)/2 + c ......... _
......

anu,> = (49/20)* 7n is a particular solution We have, a 1 = 1, l = a 1 = c+(l/2)*2 = c + 1


8n = 8n(p) + Sn(b) c=o
= (49/20)* 7"+ a 13"+ °'1,2n
3n = n(n + 1)/2

124 I lnslgh~ on Discrete structure


- - - - - - - - - - -lnsltfils
- -·o- - --:-;::-:-:--:=-:::;; --;.;--
;\~te'5tructure'I tiS
,,...
. using substitution
Solving recurrence relation a2= b1 = 5,
Solve recurrence relation We get,

au2-2a2n-1 = 1 for rel where ao = l d .


A~3 and B = -2
. uation can be converte into linear So, solution is,
This non-lmear . eq_ = an2
. b using substttutton bn ~ = 3*3" + 2*2"
equation Y b 2b , = l with bo=ao2= 12== I
Now equation become n- n- Substituting back,
. i. b = with bo = t, the homogeneous solution is · 3 .3 10g2 n- 2 . 2log2n
au=
So1vmg Un-2 n-1 1
a.2" and particular solution is c. = 3.3log2n_2n
i. = a2" + c where a and c are constants. But,
So, Un ·
•. _ 1 d b 1 = 3 we get a + c = I and 2a + c == 3 Jlog2n = 0 1ogi3
Usmg fact bo- an
So,
:.a = 2 and b = -1.
an= 3n log2 3 - 2 n
Hence the solution is bn = 2.2" - 1
= 2.2 n :.. t = 2n+ l - 1 3.4 Application to Algorithm Analysis
Substituting back an2 = 2" + I - l Binary search:
au=..Jzn+l -1 Bin~ search looks f~r .a . value in a sorted sequence and
returns the mdex of the value 1f 1t is found or Oif it is not found.
Divide and conquer recurrence relations
Input: A sequence si, si + sj, i~I sorted in increasing order a
Divide and conquer relation is of the form au = /d _+ ~n~ f 0
value key, i andj.
, , •••..,
'
Hence this equation can be looked at as_hie = chic.,+ f(d) usi~g
Outpu!: The output is an index k for which s" = key or if key is not
d" and solved. Initial condition have to be changed appropnately.
ID the sequence the output is the value O.
For substituting back, we use k = login.
I. Procedure binary search (s, i, j , key)
Q.. Solve the divide and conquer relation a,. = 3a,12+n 2. If i>j then return(O) //not found.
Where, n =r for~ anda1=l 3. K == (i + j)/2
Using change of variables the equation becomes 4 · Key == s1c then return (k) //found
5- If key <s1c thenj = k-1 //search left half
hie= 3bic., + 2" : . ul
6
The homogeneous solution bic(h) = A3" and the partJC s · Else i = k + I //search right half
solution is hie(p) = B2" 7
· (repeat the process) return (binary_ search (s. i. f key))
8· End binary search
We get,
hie= A3"+ B2" sequ Thi~ algorithm uses the divide and conquer approach. The
Since, ence is divided into two nearly equal parts. (line 3)
a1 = 1, ho = 1. So A + B = 1 • If the item is found at the dividing point (line 4), the
· hm terminates.
al&ont

....._ Insights on Discrete Structure I 127


...

d becaUse the sequence is sorted, an


. · ent this reduction ( one to determine which half f h r
• If the item 1s not ~oun '·n located the half of the sequence
. . al mpanson w1 jmpleIJ1d other to determine whether any term of th I~ tt e .1s~ t)o
additton co
.
•r
it is present. se an . f .• e 1s remam .
1·t appears• . o ence if ftn) is number o com~anson required to search for an
in which the em . k binary search (lme 7) to continue Ii t in a search sequence of size n, then
We then recursively mvo e eleflleD
• the search. ftn) = f(n/2) + 2
Example Selection sort
This algorithm sorts the sequence
Input 4 - 5 S4 = 6 and key 6
S1 = 2, s 2 = 'S3- ' S1, S2,• .. . , Sn
i = 1, j = 4, k = index
• in increasing order by first selecting the largest item and
Since (i > j) ( 1 > 4) is false
• placing it last and then recursively sorting the remaining elements.
• k= 2 Input : s,, Si, ...... , Sn and length n of the sequence
.
Smee k·ey(6) is not equal to S4(4)
• Output; s,, Si, ..... , Sn arranged in increasing order
Key (6)<st (6<4) is false ·
• 1. Procedure selection sort (s, n)
• We set, i = k + 1 =3
2. Base case, if n = I then return
i=3,j=4
3. II find largest value
s3=5,S4=6
max index = I II assime
i > j (3 > 4) is false
4. For i = 2 to n do
k = (3 + 4)/2 = 3
Since key (6) is not equal to sJ(S) If sr5mu_index then I I found larger so up date max_index = i
• 5: II more largest to end
• Key (6)<s3 (6<5) is false
Swap (Sn, Sm.x_inciex)
We set
6. Call selection_sort (s, n-1)
i=k+l=3+1=4
7. End selection sort
i = 4, j = 4, S4 = 6
bn= n-l+bn- 1
• i>j (4>4) is false
• Setk= (4+4)/2=4 ~
Key (6) is equal to s4 (6). So we return 4, the index of key
the sequence s.
Thus, binllrv . f
search reduces the search o an e e
I ment fin·"'a
-J "ow
search sequence of siz.e n to the binary search sequen tbt
. . Hence
element in a search sequence of size n/2 when n •~ even. reduced
problem of size n has reduce to one problem of size n has ded ID •
to one problem o f size. n/2. T wo compari·son are nee _____, '.
128 I lnsiahts on Discrete Structure
Insights on Discrete Structure· I 129
~'i~M~i!;J!-ti~-~1~1!~~~~~~~~~===
l ::::a1 +a2 +{-l/2) ... ..... (i)
1 1
2:::: <l1 4 1 + <l2 (-1) + (-1/2) 3 1
-=============]l
_ i•l11li
.~il•l,•~~
., recu"ence relation: a,, 3a,.., +, 2 4 a, - ai + (- l/2) 3 .......(ii)
d all the solutions OJ
ii;,• d 2 , ====
1. cin . . ._, nditions ao= 1 an a,= . /2076
a11-1 + J" with 1nin• co \ from equation (i) and (ii)
Baisalch, Back/ '\ a1 ==== l
Solution: . · 1s
f the recurrence re1atton · an -- anthl +clnlp) a2 = 1/2
The all solutions o . . 3 = 4° + (l/2)(-1)" + (-1/2)3°
. t d ti·.near homogeneous equation 1s an== 3cli,. 1 +4 0

The assoc1a e
1. Find all the solunons of recu"ence relation: I073 Bhadra
a...2
• •
Its solunon 1s 8n
(b) a,,= 7Sn-1 - 12a...2 + 3° with initial conditions ao = 1 and a, = ~
r° = 1r°· 1 - 12r°·2
r2= 3r+4
r2- 7r + 12 = 0
r2-3r-4 = 0
r2-4r - Jr+ 12 = 0
r2 - 4r + r - 4 = 0
r(r - 4) - 3(r - 4) = 0
r(r - 4) + 1( r - 4) = 0
(r - 4)(r - 3) = 0
rl =4
r1=3
r2 = -1
4° + a2 (-1)°
ao(bl =a,
r2 =4
n
Now, Finding particular solution, So(J>) 8n
(b)_
- «1r1 + «2r2n .
f{n) = 3° = «13°+ ai4°
Comparing with characteristics equation is 4 and 1, which is for particular solution
not equal to s. 8n(J>J = npo3"
Form of particular solution is npo3°= 7(n - l)po3"" 1 - 12(n - 2)J)o3n-2 + 3°
p~o=Po30 9nPo= 21npo - 2lnPo - 12np0 + 24p0 + 9
Now an= 3Sn-1 + 4 3n-2 + 3° 3po= -9
P03n= P030-I + 4 po3n-2 + 3n Po=-3
Po= Pof3 +4 Pof9 + 1 whenn=O,ao= 1
l= a,+a2
Po=-1/2
Now Sn= 3n(bl +8g(J>J when n = 1
4== a13 + «24 - 9
= «1 4° + ai (-1 )° + (-1/2) 3° 3 a, + 4a2 = 13
Putting the initial conditions, ao = 1 and a 1 = 2. I ~olving, we get,
8n = «1 4° + «2 {-1 ) + {-1/2) 3° I
0

a,== -9
1=«14° + «2 (-1)0 + (-1/2)3°
------=-=--:-~-:----:----------------
.-/1
130 I Insights ~n Discrete Structure Insights on Discrete Structure f 131

I
r

a2= 10
I

Now, solve bn = bn., + 2bn-2


Let, bn = r" is the solution of the e ua .
7
a,,= (-9) 3n+ (10)4n - n3n• I
Then r" = r"·' 2~2 + q tion
3. Find all the solutions ofthe recurrence relation:
Dividing both side by ~2
a,. = Sa.- -6an-a + 1" with initial conditions ao = I an, 01 ,
r"!r"" 2 = r"· 11r"·2 + 2~2/ r"-2
1
=4 {072 Ashwi1tJ
Or, r2=r+2
Hints: Or, r2- r-2 =0
homogeneous part Or, r2 - 2r + r - 2 = O
a,, = Sa,,.1 -6an-2 Or, r(r - 2) + I (r - 2) = o
put a,,= r" Or, (r - 2)(r + I) = o
r= 2, 3 Its roots are r = 2 and r = _1
an<Pl:: a12n+ a23D '
Hence the solution is
comparing with ftn)=p(n)sn
bn= a,r,n+ a2r2"
nm(po)sn
-bn= a,2°+ a 2(-l) 0

n(po)2D
2 To find constant a and
n(po)2n = 5 (n - 1)(po)2o- 1 - 6(n - 2)(po)2o- + 2n b- 20 • a2, we use the initial condition
o- a, + a2 (-1)0

I Po= 2/(1 l-6n)


a,,= a,,(p) + a,,(b)
= a,2°+ a23n+ n*2/(l l - 6n)*2n
I= a, + a2
Again,
b, = a, 2+ a2 (-1)
..... ······. (l)

put n = 0, ao= 1
and I= 2 a, - a2 ............ (2)
put n = 1, a 1 = 4 Adding equation (I) and (2)
then get, I== a1+a2
a1 =-1/5 I== 2 a, -a2
a2=6/S a,= 2/3
3n = (-1/5)2°+ (6/5)3°+ n*2/(11 - 6n)*2°
Putting value of
4. Find generol solution o f ~ = Jan-i + z ~ ~ 1 I= a,+ a2---
initud condition o,=a1 • l [071 M1111tl
l== 2/3 + a2
Solution: I
a,= 1/3
Here, Ja;i = +2 Jo.ri-1 Jo.ri-2
with aa=a = 1 1 1

This non-linear equation can be converted into )jneSI ,


equation by using substitution, t,. = /a:i
t ------
Insights on Discrete Structure I 133
132 I lnsllfrts on Dlsaete Structure
po= 2
Now, Sn(p)= 2.2n
bn = (2/3)2n+ (l/3f')n (p)_ z(n+ I). th .
8n - is e particular solution
Substituting back bn = an a0 = 3n(hl+ Su(p)
ao=b/
0
= a3"+ a2" + I
=(2°+ 1/3 + 1/3(-1) )2
To find solution, we use initial cond"1tion
.
Find all solution of the recurrence relation an = 3a,._, +l
5. ao= 5
with initial condition a,= 5 /071 BhadrqJ
ao= a30+ zo +I
Solution: S=a +2
ao=3ao-1+ 2°
a =3
The associated liner homogeneous equation is
an= 3.3"+ zn + I
an= 3ao-, ao=3o+1+zn +I
Let an= r" be solution,
1
Then, r"= 3f"
r=3
0
The homogeneous solution is 3oCh6aJ
Where a is constant,
Now, finding particular solution
ftn) = 2°
0
Comparing with ftn) = p(n)s
Wegets=2
The root of the characteristic equation is 3. Here, s is not the
root of characteristic equation of the associated linei
homogeneous recurrence relation. There is particular
solution of the form,
-Po.2°
Now, equation
au= 3Sn-, + 2° becomes
Po-2°= 3.Po.2n- 1 + 2°
Po,2°= 3.Po.2°/2 + 2°
2Po= 3Po+2

134 I Insights on Discrete Structure Insights on.Discrete-Structure I 135


....,...
cl

Graph Theory c6
c2

4.1 Graph __
c3
Graph is a discrete structur~ consisting of vertices and edges.
c4
Edges connect the vertices.
Fig,: Graphca/ representation 0 , .
A graph G = 01, E) consists of two parameter. .
'l seven committee o••
- 'l acompan

A set V = V(G) whose elements are called vertices or nodes A graph consist of a finite n tr
vertices and a set E of element sub~eity set V of objects called
O
ofG. is a pair of two sets V and E verte V called edges. So graph
A set E = E(G) of unordered pairs of distinct vertices called • x set and ed '
ii. Vertices are also called . ge set respectively.

I
edges ofG. sometimes caJled lines or arcs. pomts or nodes. Edges are
The vertex of set G is V(G) = {
. Let us suppose that a publishing company has ten editors in E(G)= { { Ci, C2}, { CJ, C3} { C C} Ci, C2, . .. C7} and the edge set
different areas. These ten editors have a standard meeting time C2, C7},{ c3; C4},. { C3, Cs} {,C4
'
c''}s{ , { C1 ,}C7}, { C2, C3}, { C2, C4} {
' s • C4, C6 { C C } { '
during the first Sunday of every month and have divided • The number of vem· . G . ' 4, 7 , c6, C1}}
. ces m is often II d
themselves into seven committees to meet later in the day to while the number of ed . . . ca e the order of G
. ges 1s its srze w
Ofd er and s12e respectively · e use n and m for
discuss specific topics of interest of company.
• Since the vertex set of eve . .
The 10 editors have devided on seven committees C 1 = {I, 2, every graph is at least I . ry graph is non-empty, the order of
3} , Ci={l,3,4,5}, C 3={2, 5, 6, 7}, C4={4, 7, 8, 9}, C 5={2, 6, 7),
• · A graph with exact( Yone vertex
• .
1s called a tri • 1
Cc;={8, 9, 10} Cr{l, 3, 9, 10}
4.1.1 TfPes of Graphs vra graph.
They have set aside three time periods for the seven
committees to meet on those Sundays when ten editors are present 1. Labeled graph
2 - Unlabeled graph
Some committees can not meet during the same period because one
or two of the editors are on both committees. a
In this figure, there are seven small circles representing the
seven committees and a straight line segment is drawn between tw0
circles if the committees they represent have at least one committee d
member is common. In other words this means two committee witb
8
common committee memebe should not be scheduled to meet at
same time.

Fi',g.: lab l d ·
--------- e e graph Fig.: Unlabeled graph

136 I Insights on ~ete Structure Insights on Discrete Structure I 137


.......
'
A~~_!U~n~d!!ir~e~c~ted~~an~d~D~i~re~c~t::'.ed~G::..:r:..:a:!:p:.._h_s_ _ __ _ _____
~-2 I 4.2.3 Directed Graph (Digraph)
A directed graph (V, E) consists of set of y f .

I
4 2.1 Simple Graph h d . 0 vertices a s t
• h 1. i-tuple consists of non-empty set of vertices E of edges t at are or ered pairs of elements 0 f V In . ' e
. . this graph. •
Simple grap ~ . 0 f distinct elements of vertices called
I op is allowed but no two vertices can have ·
o . A d. . mu1tip1e edges in
v, a set of unordere th~aigrarsph as G = (V E). This kind of graph me direct10n. lfected graph having . .
w represent 1s '. . caIIed onehted
sa·.rected edges 1s . 00 symeetric pa1s of
graph A comp! t .
edges. e
bas undirected edges, no
loops and no multiple edges. dl
is called tournament. · e e onented graph
b
a

e
C

D,
D2 is oriented graph
Iv
Fig : Simple graph

In abov!! graph G = (V, E) , set of vertices.


V (G) or v = {a, b, c, d, e} and set of edges.
E (G) or E = { {a, b}, {a, c}, {b, c},{b, d},{c, d}, {c, e}, {d,
e}}
4.2.2 Multigraph

I In a graph, two vertices are either adjacent or they are not, '
that is two vertices are joined by one edge or ~o edge:;
multigraph M consist of finite non empty set V of v~~ices andfinite
of E of edges where every two vertices of M are Jomed by
4.3
Fig.: Directed mutligraph

Graphical Terms and Terminologies


number of edges. . th
4
• If two or more edges join the same pair of vertices, en .3,I Adjacent, Incident, and Degree of Vertex ,
these edges are called parallel edges.
A~jacent: Two vertices u, v in an undirected graph G ·are ~ailed
• In multigraph muliple edge occurs. adjacent or neighbor if {u, v} is an edge.
. . a vertex
• In a pseudograph, an edge is also permitted to JOJO
ln{cident: The edge e is called incident with the vertices u and v if e
to itself. Such an e d g ~ ·( \ : : : u, v}

Dega:-ee of a vertex
ed :he degree of a vertex is undirected graph is. a number of
v _&es incident with it, except a loop at a vertex. Degree of a vertex
M, ~ ~
v is denoted by deg (v). A vertex of degree zero is caJled isolated
Fig.: Multigraph (Every graph is a multigraph)______, erte,c and
~ e with degree one is called pendant vertex.
138 I tnsightson8tsa_ete~truttore
Insights on Discrete Structure I 139
Loop in a vertex counts ·twice to the degree. e.g.: find the f}teorem 1:
The Handshaking Theorem
degrees.
b Let G = (V, E) be an undirected graph with
=== l:veV deg (v) a edges Then 2e
b
a r--------.-

f e
d f
deg (a)= 2 deg (b)= 3
Proof : d
deg(c) =4 deg (d) = 2
deg (f) = 2 deg(a) = deg(t) = deg(d) = 2
deg (e) = 3
deg(b) = deg(e) = 3
Let (u, v) be an edge representing edge of a directed graph G,
deg(c) = 4
u is called adjacent to v and v is called adjacent from u. The vertex
v is called initial vertex and the vertex v is called terminal or end We have
vertex. Loop had same initial and terminal vertex. LHS =2*e
In directed graph the in-degree of a vertex v, denoted by deg· =2 x 8=16
(v), is a number of edges, that have v as their terminal vertex. The · RHS = Lvev deg (v)
out:-<Iegree of a vertex v, denoted by deg+(v}, is the number of = 2 + 2 + 2 + 3 + 3 + 4 = 16
edges that have v as their initial vertex. Therefore, LHS = RHS
Loop at a vertex adds up both in-degree and out-degree to Theorem 2:
one or more than calculated in-degree and out-degree. 0

An und 1rected graph bas an even number of vertices of


Q. Find in-degree and out-degree of each vertex odd degree.
In-degrees: I • Let VI and V 2 be set of vertices of even and odd degrees
deg · (1)=2 respectively. In an undirected·graph G = (V, E)
deg ·(2) = 3
We have
deg .(3) ~ 2 2 '
~ deg ·'(4) = 1 le== Lvev deg (v) = Lvevi deg (v)+~vev2 deg (v)
Out-degrees: 4 · ~rom equality above, we can say the left part is even i.e. 2e
deg +(l) = l rs even, the sum of deg (v) for v £ V 1 is even since evety
deg +(2) = 1 Vertices has even degree. So for the left hand to be even sum
3 of deg (v) for v e V 2 must be even. Since all vertices in the
deg +(3) = 1
d~g +(4) .=4 set V 2 have odd·degree the number of such vertices must be
~ n for the sum to be even.
140 I Insights .on Discrete Structure Insights on Discrete Structure I 141
r
Which vertices in following graph are isolated which are A complete graph of order n . d
Q. pendant and what is maximum degree? What types of • · · t rf is enoted b 1,-
d1stmc ve ices of ko are joined by an edge Y ""·th Since every
graph is it? pairs of vertices in k is (n)
th .
2 e size of ko is
' e number of
c;)
n
d
a n(:-1)

0 e 4,3.3 Cycle:
J The cycle Cru n~3, consists of .
• edges {v1, v2}, {v2, V3} {vn vert}1ces. v1, v2, ······ v and

D □·v·o.
f
b
Vertex f is isolated, vertices a, d and j are pendant.
Maximum degree is deg (h) = 5. This graph is pseudograph
(undirected loops) C3 C4
4.3.4 Wheel: cs
Q. Determine the number of its edges and sum of the degrees
ofall its vertices. ~en a new vertex is added to a c
vertex 1s connected to each of th . ycle Co and this new
There are 9 edges and sum of degrees is 18. wheel Wn. e n vertices in Cn, we obtain a

Theorem 3:
The sum of the in-degrees of all vertices in a digraph =
The sum of the out-degrees= The number of edges.
Let G = (V, E) be a graph with directed edges,
Then,
I:vevC deg-(v) )= I:vev(deg + (v) )=IE I Ws

4.3.2 Complete graph 4.3.S n-cubes:


• The ~omplete graph of n vertices is the simple graph that
con~ exactly one edge between each pair of distinct 11 The n-cube denoted b Qn · th
~11esenting the .2"
b. . Y , IS e graph that has vertices
vertices. adJacent if and nl . it stnng of length of n. Two vertices are
exactly one b ·1 o . ~ if the bit strings that they represent differ in

_____•
1 position.

0 .,_ 110 111

010
k.i ks
01 l
Fig: Complete graph

142 I Insights on Discrete Structure


'-------- ------------.-,- -- - - - - - -
Insights on Discrete Structure f 143
_ .7 Representing graphs
ll 43 a
IO

00 Ol

4.3.6 Operations on Graphs


4.3.6.1 Sub graph
A subgraph of a graph G = (V, E) is a graph H = (W, F), C

where W £ V and F £ E. Fig : 1

1. Edge list for simple graph


Vertex Adjacent vertices
a b,c, d
b a, d
Cs
C a,d
ks d a, b, C
sub graph of Ks 2. Edge list for Directed graph
Initial Vertex E nd vertex
4.3.6.2 Union
a b
The union of two simple graphs G 1=(V1, E 1) and G2 = (Vz,
Ei) is the simple graph with vertex set V = (V IUV 2) and set E = b C
a
C
(E1 UE2 ) . The union is denoted by G 1UG2 b
d

J
a, b, c, d

0- 4 b

I\. Ws
Ss Cs
C

Flg:2

144 I Insights on Discrete Structure


______ :...__ ________
Insights on Discrete Structure I 145

T
The order of vertices be a b c d f
' ' ' ' e, , and ed
4.3.8 Adjacency Matrix: eJ e4, e5, e6 , e 7 , e 8, e9 ges order be el
· Given a simple graph G = _(V, E) with !Y \=n of the vertices e2' ' '
of the graph are listed in some arbitrary order hke V 1. V 2 , • . •• • . •V ,Adjacency Matrix:
the adiacency matrix A of G, with respect to the order of vertices ~• a b C d
~ .h h d' . IS e f
n-by-n zero-one matrix (A= [aij]) wit t econ itton a 0 I 0 0 0 I
l 0 I ,
·· = {1 if(Vi, Vj) is an edge of G b
0 I 0
I I l
au o otherwise C 0 I I
(
d 0 I 0 0
Adjacency matrix for undirected graph is symmetric, in case 1 0
of pseudograph or multigraph the representation is similar but the e 0 l l 1 0 0
matrix here is not zero-one matrix rather the (i, j t entry of matrix f l l l 0 0 0
contains the no. of edges appearing between the pair of vertices.
Incidence matrix
_ In case of directed graph, we can extend the same concept e1 e2 e3 e4 es e6 e1 es eg
as in undirected graph as below a I 0 l 0 0 0 -0 0 0
a;·= {1 if(Vi, Vj) is an edge of G b 0 I I 0 l 0 l 0
1 o otherwise 0 0 0 I I
C I 0 0 0
4.3.9 Incidence Matrix d 0 0 0 0 0 0 0 l I
Given an undirected graph G = (V, E). Assume that e 0 0 0 0 0 I I 0 1
vertices of the graph V 1, V 2 • • • • ••• • • ••••• • • VO and the edges of graph f I I 0 I 0 0 0 0 0
are e,, e2 ... .. .. ... ... .. em . The incidence matrix of a graph with
el
respect to the above ordering ofV and Eis n by m matrix. Where
m;; = {1 when edge, is incident with Vl e5
d
0 otherwise
. ~en_the graph is not simple then graph can be represented
b~ usmg mcidence ~trix where multiple edges corresponds to two e2
di~erent columns with exactly same entries. Loops are represented
with column with only one entry.
e3 b e8
a d b
·eIO
C
Ad· e3 e
e9
Jacency matrix
I I 0 I 0
I 0 2 0 0
0 2
e
0 I I
I 0
f 1 0 3
0 0 I 3 1
146 I lnsigh~ on Discrete Structure ~
Insights on Discrete Structure I 147
Incidence matrix A. function f from A to B is called
e6 e1 es e10 one-to-one (or 1-1) .f
e1 e2 e3 e4 es whenever 1
0 0 0 0 (b) the~ a = b.
a 1 l 0 0 I
0 0 0 0
I (a) ==nef element m A.
No element of B is th .
e image of more
b O 1 1 l 0 than O
c O O l 1 0 1 0 0 0 In a one-to-one function , given any y th .
. . ere 1s only O h
d O O 0 0 1 I l l 0 0 be paired with the given y . Such functio ne x t .at
can ns are referred to as
e O O ') 0 0 0 l injective.

f A B
.. Onto"
. NOT "Onto"
(all elements m B are used) (th d .
8
e an 1 10 Set B are not used)
A. function f from A to B is called onto if for all b in B there
g is an am A such that/(a) = b. All elements in Bare used.
Adjacency matrix
a b C d e f g h Such functions are referred to as surjedive.
a 0 0 1 0 0 0 0 0
b 1 I 1 1 0 0 0 0
C 0 0 0 1 1 0 0 0
d 0 0 0 1 1 0 0 2
e 0 0 0 0 1 1 0 0 B A
f 0 0 0 0 0 0 I 0 "One-to-One" NOT "One-tlrOne,.
g 0 0 0 0 0 I 0 0
E.g. : G == (V. E) and H(W, F)
h 0 0 0 0 0 2 I 0
q
ar--------b p
4.3.10 Isomorphism of Graphs
Two simple graphs G 1=(V 1, E 1) and Gt=(V2, E2) arc
isomorphic if there is a one-to-one and onto funcdon f from Vi '°r ,

f(a) and f(b) are adjacent in G2 , for all ~ and b in V1. sue
1
V2 with the property that a and b ar~ adjacent in G 1 if and 001~ a : C -G d r s
function is called isomorphism. one 1he function f with f(a) = p. f(b) = s. f(c) = r. f(d) =q is a
to one
correspondence between V and W.

148 I Insights on Discrete Structure Insights on Discrete Structure I 149


aoth graphs have eight vertices and ten d
t,oth have four vertices of degree two ande figes. Also' the · Y
We can show two simple graphs are not isomorphic b degree three. However, G and H . our vertices of
showing they don't share a property is called invariant. The~ . G are not iso .
deg(a) == 2 ID , a must correspondence to ·morphic.
h Since
· ,
properties are described as follows: in H because these are the vertices 0 f d eu er t, u, x or y
1. Isomorphic simple graphs must have the same number of . egree tw0 ·
each of these four
. vertices in H is ad'~acent to m H. Here
h '
vertices. of degree two ID H, which is not true 1or
c .
a G anot er vertex
10
2. Isomorphic simple graphs must have same number of
Another way to see that two graphs are not iso
. · .
edges. note that subgraphs fonned by conn . morph1c is to
3. The degree of vertices must be same because the number . ectmg the d
vertex with same degree in both h e ges from the
of edges from the vertex is detennined by degree. isomorphic. For e.g.: subgraphs of Gt e graphs are not
nd
vertices of degree three and the ed a H .made up of
Example 1: not isomorphic. ges connecting them are
Show that the graphs displayed below are not isomorphic:
s
b b
f

a a
d G
V

H
e e
To show isomorphism of hs .
matrix For th"d" grap ' we can also use adJacency
H . ts, a ~acency matrices of two graphs
G Example : are same.
3
Both graphs have 5 vertices and six edges. But H bas a Detennine w hether the graphs are isomorphic
vertex ofdegree one, namely e, whereas G has no vertices of a
degree one. Hence G and H are not isomorphic. b s

Example 2: e f
b s
a

f d
e C V
G H
g
·
Both gra h
four v _P 8 have six vertices and seven edges. Both have
h
d------__JC ·, Also, ert1ces
Sub of d egre~ two an~ two vertices
• of degree three.
; &raphs ~phs are 1somorph1c. Here, we cannot say these
G H
i ~ e isomorphic or not. For this, we can use adjacency

Insights on Discrete Structure I 151


150 I Insights on Discrete Structure
...

vertices a, b, c, d, e, f ~nd w, t, u, v, 6 for first graph and c, a, b, e d and f .


same. ' . In the second graph are
matrix with the ord~r ~f matrices after drawing adjacency
x we can see sunilar h are isomorph'ic. £JalDPle 5:
s, · these grap s
matrices. Hence,
-a b

C

l
e f
- h
Example 4: .
Determine whether given tw
I
0
graphs are isomorphic or not?

a
_ _ _ _'"""'?rb d
g
I
.. 2 4
• 5 6
.8
2 C

f
I
3 I
7
Both graphs have 8 vertices 7 edges in both hs
5 . ' · grap two
d vert1~e~ have d~gree 3, 4 vertices have degree 1 and
remammg. 2 vertices have degree 2· Since
· , the mvanants
· ·
agree m ~o~h ~e graphs, we can continue to get the function
6 such that 1t 1s isomorphism.
In above graphs, no. of vertices are same, no. of edges is
same and all vetices in both the graphs have degree 3. However,_ in case of first graph, the subgraph containing
vertex with degree 3 is not isomorphic with any graph
Since the invariants agree on both the graphs, we can try out
formed by connecting edges with vertex 2 or 6 (both of
to find the function that is isomorphism. Take the sequence
degree 3). Hence, two graphs are not isomorphic.
of vertices from the first graph as 1, 2, 3, 4, 5 and 6· N~w,
define f(l) =·c, f(2) = a here, there is adjacency preservation 4·4 Bipartite Graphs, Planar Graphs, Regular Graphs
since we have {1,2} as and edge in the first graph where as 4•4•1 ·Bipartite Graph
. ·1 ly we
·{f(l), f(2)} = {c, a} is an edge in second graph. S1m1 ar ,
can assign f(3) = b, f(4) = e, f(S) = d, f(6) = f. .. A simple graph G is bipartite if its vertex set can be
between
Since we found one to one correspondence hs ~~honed into two disjoint subsets V1 and V2 such that every edge
verticesof two graphs preserving the adjacency, above graphs V ~ graph connects a vertex from the set V I to the vertex of set
2 0
are isomorphic. Here, the adjacency matyrices of t:W0 grai J. · two vertices of the same set are connected by an edge.
in which vertices are ordered in terms of function 1.e, 1, 'nd Q. Is c, Bipartite ?
4, 5 and 6 for first graph and c, a, b, e, d and fin the sel:o
I 2
graph are same.
. pb5
One to one correspondence between vertices of two gra
3
preserving the adjacency, above graphs is isomorphic. .
Here, the adJac,
.
. ency rnatyrices of two graphs in
. ..A '
4 5311' '
* 1
6

ve~,ces are ordered in terms of function i.e, 1., 2 ~ , '------__


5 4
152 'I Insights on Discrete Structure -------,n-sl_gh_ts-on-01=--scr-e---:t-e-=stru=ctu=re:-;--115;;;
3- - -

esarople:
. . ed into two sets V 1 = {1,3,5} and v for
be partttton . . 2 Draw the graph below as planar representation of the
Its vertex set can nects a vertex m V, with a venex in
={2, 4,6} every edge of C6 con graph.

V2.

Solution
1.

Not all graphs are planar


So, c 6 is a bipartite graph. It may be difficult to show that graph is non-planner. We
Q. Is K3 Bipatite? would have to show that there is no way to draw the graph without
any edges crossing.

=No
/\
3L------~ 2
Regions
Euler showed that alJ planar representations of a graph split
the plane into the same number of regions, including on unbounded
region.. ·

Complete Bipartite Graph · R4


. . h v · the graph where the
The complete b1part1te grap n,m, n ts .
· · · d · t tw subsets of m and n vertices. R4
vertex set 1s part1ttone m o o · . ·r
respectively. In this graph, there is an edge between ~o vertices ,
and only if two vertices are in different sut!>sets of vertices.

. . g ·• K 2,5
E•• E.g. : K1.s
V• and V5 •
Any planar representation of K.3,3 V1 and V2 connected to

cl The four edges {Vi, V4 },{V,., V2 },{V2 , V5},{Vs, V,} form a


osed curve that splits the plane into two regions R1 and R2.
vl v2 v3
v5 vll

R2
Rl
4.4.2 Planar Graph ,
A graph is called a _planar if it can be drawn in tbe ~~ V4 -
v4 v5
without any edges crossing such drawing is called a p v2 Fig. l
Fig. 2
representation of the graph. ___-/

154 I Insights on Discrete Structure Insights on Discrete Structure I 155


. ust be either in R 1 or R2- Assume V 3 is in R Euler devised a formula for express·Ing the relati h'
N ext , V 3 m . 2. en the number of vertices, edges and . ons 1p
Then edges (V , v 4 ) and (V3, Vs) separate R2 mto two sub regions betwe · regions of a· planar
3

R21 andR22.
vl _____ _, v
graph.

These may help to determine if a graph ca be 1

Euler's Formula:
n P anar or not.

R Let G be a connected planar simple graph with


d
• e e ges and v
R vertices. Let r be the number of regions in a planar
V V V
representation of G. Then r = e-v + 2
V

Now, there is no way to place vertex V 6 without forcing a


R4
crossing.
• If V6 is in R1, then (V6, V3) must cross an edge.
• IfV6 is in R2 1, then {V6, V2 } must cross an edge.
• IfV6 is in R22, then {V6, V1} must cross an edge.
• Alternatively assume V3 in R l . Then the edge (V3, V4) and no. of edge, e =6
(V3_ V4) and (V3, Vs) separate R, into two sub-regions R, 1 no. of vertices, v =4
and R12. no. of regions, r = e - v + 2 =4
Rl2
Corollary 1:
If G is a connected planar simple graph with e edges and v
vertices where v;:::3 , then es)v-6
Rll
For example:
R2
Is Ks planar?

v2

8
Now there is no way to place vertex V 6 without forcing
crossing. k~
• If V 6 is in R2 , then {V6, V 3 } must cross an edge. Ks has 5 vertices and l Oedges.
• IfV6 is in Ru, then {V6, V2 } must cross an edge.
Here , y:::3
So• 1·r Ks ·1s planar, it must be true that
• If V6 is in R12, then {V6, V1} must cross an edge.
e 5._3v - 6
Consequently, the graph K3, 3 must be non- planar.
3
v. 6 =: J. X 5 • 6 = 15 - 6 = 9

156 I rnslghts on Discrete Structure -----------::-:---:-:=:==.~-


lnslghU on Discrete Structure I 157
-- Thus, e roust be less than or equal to 9
..,,..

'[ZI ~C2J
Bute== 10
Therefore Ks is non-planar.

Corollary 2 : ·~f
If G is a connected planar simple graph, the G has a vertex of d c dl[;__/
G GI G2 e
degree not exceeding 5.
Corollary 3: Graphs G1 and G2 are.homeomorphic to the graph
If a connected planar simple graph has a edges and v vertices
J(uratowski's _Theorem (Planarity Testing Algorithm)
with V2'.:3 and no circuits of length 3, then e~2V- 4
A graph is non- planar if and only if it contains a sub h
For example: homeomorphic to Kl. 3 or Ks. grap
Is K3 3 planar? v2 v3
. vll Forenmple:

v4 v6
vs
e
k3,3
K3, 3 has vertices = 6
K3.3has edges = 9
Here, v2:3 and there is no circuits of length 3, If KJ. 3 were
.
Solution
b C

planar, then e-9,v- 4 would be true.


2V-4 a d
=2X6-4=8
So, e must be ~8
Bute=9 f b e C
'
Therefore KJ. 3 is a non-planar.
• If a graph is planar, so will be any graph obtained by
~ving an edge {u, v} and adding a new vertex w togetber a
with edges {u, w} and {w, v}. such an operation is caUedall
el~1:81)' sub-division. The graphs G 1= (V1, E1) 111 -~
G2=(V2, Ei) are called homeomorphic if they can be obta b
~1_11. the same graph by a sequence of elementarY sll f e
d1v1s100. Above graph is homegrapnic to Ks, the given graph is not
Planar.
158 I l~ts on Discrete Structure -------------.::--:--.~--
I 1nsights on Discrete Structure 159
u
4.4.3 Regular Graph V

In graph theory, a re~lar-gra~h is a graph where each Vertex


has the same number of neighbors t.e., every vertex has the sa
degree. A regular graph with vertices of degree k is called a~~
regular graph or regular graph of degree k. Regular graph of de X
y
at most 2 are easy to classify. A o-regular. graph consist~eef 0
disconnected vertices a 1-regular graph consists of disconnected w: x, y, w, y, v, w is therefore a walk. Len h .
no. of edges. Here 5 is the length. gt of walk 1s the
edges, and a 2-regular graph consists of disconnected cycles. A 3_
regular graph is known as cubic graph. A walk of length O is a trivial walk.
We define
• a u-v trail in a graph G to be a u-v walk m
. which
.
• no edge 1s traversal more than once.
• •
Since w:x, y, w, y, v, w is not an x-w trail as theed e .
• • repeated. g wy is

• T: u, w, y, x, w, vis a u-v trail.


Trail T repeats the vertex w.
o-regulargraph 1-regulargraph 2-regulargraph 3-regular graph
A u-v walk is a graph in which no vertices are repeated in u-
4.5 Walk Paths, Circuits, Components v path.
P : u, w, y, vis a u-v path.
Walk: l~ no vertex in a walk is repeated then no edge is repeated
A walk is defined as a finite alternative sequence of vertices either. Hence, every path is a trail.
and edges of the forin. A circuit in graph G is a closed trail of length 3 or more.
Hence, a circuit begins and ends at the same vertex but
repeats no edges. In a circuit, vertices can be repeated in
Which begins and ends with vertices, such that addition to the first and last.
1. Each edge in the sequence is incident on the vertices For example:
preceding and following it in the sequence. C.
· Y, W,. U, V, W, X, y
8
A walk that begins and·ends at the sanie vertex· is called • e·x
· • Y, W , U, V, W, X
closed walk. A walk that is not closed -is an open walk. lf_u c: W, X, y, W, U, V, W
15
be initial vertex, v be tenninal vertex. If u = v, then walk w ' is a circuit.
closed and U=FV it is open. As we move from one vertex of~ Cycle
to next,. we are ac~lly encountering or traversing ed_ge~e
G, Possibly traversmg some edges of G more than once.. 1 A circuit that repeats no vertex except for the first and last is
number of edges encountered in a walk (including multlP e a cycle. A K-cycle is a cycle of length K. A 3-cycle is also referred
occurrence of an edge) is called the length of the walk, to as a triangle. A cycle of odd length is called odd cycle, a cycle of
even le h.
ngt 1s called as even cycle.
--------.:.__ _ _ _ _ _--:::----::-;.=::::~~-
Insights on Discrete Structure 1161
160 I Insights on l)lscrete Structure
For example: cut Sets and Cut Vertices
C' = x, y, v, w, xis a cycle.
!:---"
7 .
cut Edges and Vertices
~4~.6~~C~o~n~n::_ec:::t::d::n.:::es::s~A.::l~g::..or:...:l_th_m_ _ _ _ _ _ _ _ ____ Acut vertex is a vertex, by removing wh·ie.h one can ··
the graph to more connected components. Partition
Connectedness
A cut edge is an edge by removing wh' h
• An undirected graph is called connected if there is a path IC one can partiti
the graph to more connected components. on
between every pair of distinct vertices of the graph.
• There is a simple path between every pair of distinct vertices
If multiple edges need to be removed to art· •
· · f P 1hon the graph
then the rrummal set o such edges are calledcut set. '
of a connected undirected graph.
Q. Find the cut vertices and cut edges /n thefi011ow,ng
,, · . graph:

.v1d VJ r:b
b
a a b

f d
d C
d C
G H b c e h
f
Graph G ls connected but graph H ls not connected. Cut vertices : c and e
Cut edge ; {c, e}
• A graph that is not connected is the union of more than one
connected graphs that do not share the common vertex. Vertex V is cut vertex of G iff deg v>2
These disjo~t connected sub graphs are called connected Connectedness in Directed graphs
components of a graph.
th A directed graph is strongly connected if there is a directed
For example: pa between every pair of vertices.
What are the connected components of the following graph? betw A directed graph is weakly connected if there is a path
b d-------- e F een every pair of vertices in the underlying undirected graph.
f or example:
Q,N. ls thefi ,
o,'/owing graph strongly connected?
a b
a C
g
b------
C
Connected components are {a, b, c,}, {d, e}, {f, g, h}

e
d
162 I Insights on Discrete Structure '-------------:-----:-:---:--:--;-;;:--
Insights on Discrete strueture 1163

The graph is strongly connected because there is a d' Eulerian Graph


. f . If •rect .~ 48
~
path between every pair o vertices. a directed &raph e~
Euler path and circuits
strongly connected, then it must also be weakly connected is
A circuit C in a graph G is called . .
Is the following graph strongly connected? · ontains every edge of G . Since no edge ts. Eulerian circuits
repeat d • . if c
2. b C
ever/ edge appears exactIy once in Eulen·an c·1rcu1ts.
. e m a circuit'
a
A connected graph that contains as E 1 . .
Eulerian graph. · u enan circuit is called
C

for example:

e d
This graph is not strongly connected because there is no
directed path between a and b, a and e etc. 4
5
However, it is weakly connected (imagine the graph as an
undirected graph) 7 8 9
The subgraphs of a directed graph of G that are stron~y
connected but not contained in larger strongly connected subgraphs Euler circuit is I, 2, 3, 6, 9, 8, ?, 4, 5, S, 6, 5, 2
(the maximal strongly connected subgraphs) are called the stron~y For connected graph G, we refer to an open trail that contains
connected components or strong components of G. every edge of G as an Eulerian trail

For example:

I graphs:
What are strongly connected components of following

a
b

C
T-
- u'S, t, U, V, W, y, U, W, X, Z. W
An euler path 1s
· a path usmg
. every edge the graph exactly
e 0
d nee. 1 ~--....:.....---- 2
This graph has three strongly connected components
• The vertex a
• The vertex e
• The graph consists of
V= {b, c, d} and

__
4
E = {{b, c}, {c, d}, {d, b}} No E I .3 .
~er CtrCUlt exist
-~~~--__:_, ____-/ Insights on Discrete Structure I 165
164 I Insights on Discrete Structure
T

.9 Hamiltonian Graph
Necessary and sufficient conditions 4
aainiJton Paths and Circuits
A connected mutligraph has a euler circuit iff each of .
1
vertices has an even degree. 1s A cycle in graph G that co ta· ·
. I C n ms eve
Hamiltontan eye e. ertainly a gra h ry vertex of G 18
.
A connected multigraph has a eulerian trail iff ~xactl If h P G (n> 3) · called
in G. a grap contains Hamil -:-- is Hamilto . a
vertices of G have odd degree . Y two Hamiltonian path. tonian cycle .t nian P~th
u v , I contams
For example: w
Q.

I. ad Zb,
Which of the following graphs is a ~ularian circuit?

2 •
b

d
Yes No
(a, e, c, d. e, b,-a)

d
C e (a, b, c, d, e, a)
d (a, b, c, d)
No
Hamilton circuit
Euler trail : (a, c, d, e, b, d, a, b)
For ffamilton Cll'CUit
.
Eulerian for Directed graph
No vertex of degree I
A non trivial connected digraph D is eulerian if and only if
od V = id v for every vertex . If a node has de . .
z , ~ any Ham.ilto . ~~ 2,. then both edges mc1dent to it must be
Cll't:uit. n crrcwt mc1dent to it must be in any Hamilton

No smaJie . . . . .
, 8~end P0int r crrcmts con~ed ~ any Hamilton circuit (the
X 19,,ice). of any smaller circwt would have to be visited
ASuff• •
ic1ent condition .
~e~ Ghea connected simple graph with a vertices with n2'._3.
C: u, v, w, y, z, x, y, x, w, u., ~ m i l t o n circuit if the degree of each vertex is 2'.. n/2.
u
is eulerian circuit. lnsi,hts on Discrete Structure I 167
166 I Insights on Discrete Structure
Weight can represent distance, cost t' ·
For example 1: . ' •me, capacity etc
a The length of a path m a weighted gra h . .
weights on the edges. p •s the sum of the
Shortest Path
There are several algorithm that find h
d
. . . a s ortest path betw
two vertices m a weighted graph. Dijkstra's al . . een
of them. gonthm 1s one
ln this graph, there is no hamilt~n circ~it since node has
degree "'.t. and both. edges from it must be. m Hamilton circuit whi'ch Dijkstra's Algorithm
is not possible one of the hamilton path ts a, b, c, d, e.
Procedure Dijkstra (G: weighted connected .
Example 2: 2 3 with all weights positive) · simple graph

G has vertices a = v0, v 1, . . . . ... ..... .., Yo==


2 and we·
v;) is notan edge in G. igbs (v;,
4
Fori=ltox
L(v;) = oo
7 8 L(a) = 0

In graph, we can have hamilton circuit, the circuit can be I, s :: = 4>


2, 3, 5, 6, 9, 8, 7, 4, 1. Since, there is circuit. We can have path
{ the labels are now initialized so that the label of a is O d
also. all other labels· are oo and s is an empty set} an
Dirac's theorem: Whiie z Es
lf G is a simple graph with n vertices with 02:,3 such that the
Begin
degree of every vertex in G is at least ~ , then G has a hamilton
circuit. u: a vertex not ins with L(u) minima
Ore's Theorem: . s: s {u}
lf G ·is a simple graph with n vertices with ::::,3 such tha! d~ for all vertices u not in S.
(u) + deg(v)2:.n for every pair.of non adjacent vertices u and v 10 '
then G has a Hamilton path. ifL(u) + ( .
w u, v) < L(v) then L(V) : = L(u) + w(u, v)
{th·18
_4_.l_O_A_S_ho_rt_es_tP_a_t....:.h....:.AI~g!:!.:o:.:.n.:.:·t=hm=----------- labels of a~ds a vertex to s with minimal label and updates the
1. Weighted Graphs Vertices not in s}

Graphs that have a number assigned to each edge (u, v) has' E~d {L(6) ::::{ length of a shorter path from a to z}
weight(u, v). Each weight is a real number.
----:-:--:--------------__-/ '
168 I Insights on ~ete Structure lnslahts on Discrete Structure I· 169
'thm to find the shortest path fro,,, the 3(a,c)
01 4) S(a, c, b)
QN,l. Use Dijkstra's. !":fiollowing weighted graph given be10111
vertices a to z ,n t . 5 d
5 d
b 0 4

l) 00

a
z
0 2
z

2(a) 10 12(a,c)
10 e
C

00
0 e

5 d 3(a,c) S(a,c,b)
b
2)
00 5)
0
z 0 d 6~
a
14(a, c, b, d)
z

C e 3
2(a) 10(a,c,b,d)
e

3)
4(a)

5 d
00 0 00
3(a,c)
6
6) d
0 4 .b 5
00

z
8 2
00

2(a) 10 00

-0 e 2(a)
10 12(a,c).
e

170 f Insights on Discrete Strutture ---------------::::::::-;-;.;;ct;,;,~ -11


Insights on Discrete Stru u ,
:i1-flf1~-- -
7) 3(a,l:)
B(a,c,b)
---
L(a)
L(b)
s cp
0
00
{a}

0
4
{a,c}

0
3
{a,c,bJ
0
3
{a,c,b,df

0
3-
{a,c,b,d,e}

0
3
{a,c,b,d,e,z}
0
5 ..- 3
L(c) 00 2 2 2 2 2 2
0 4 13(a, c, b, d, e) L(d) 00 00 IO 8 8 8 .8.
z ---L(e) 00 00 12 12 10 10
0 2
-L(t) 00 00 00 00 14
Hence, the shortest path from a to z has length L(z) = 13
13
IO
13

10 tO(a, c, b, d)
· 2(a)
Q2) b 5 d

0 0
a f
B(a,c,b)
3(a, c)

() 6 Q3) b
r
5
5
d
Q

6 ff
0 4 13(a, c,b,d,e)

0 a 2 h
2 3

2(a)
10 lO(a,c,b,d)
C 10 e 5 g

0- 0 The travelling salesinan problem


The travelling salesman is one of the classical problems in
w(u,v) A b C D e Z - - c?~puter science. A travelling salesman wants to visit a number of
A 0 4 2 00 00
--
ct)
cilles and then return fo his strarring point of course be wants to
B 4 0 I 5 00

IO
--
ct)

ct)
save tune
· and .energy. So he wants to detennine the shortest eyele
for his trip.
C 2 I 0 8
0 2 -----6 We can represent the cities and the distances between them
D
E
00

00
5
00
8
, IO 2 0 -----
~
bYaw ·
eighted, complete, undirected graph.
2 00 (X) 00 6 3 -~ total T~e problem then is to find the shortest cycle of minimal
Weight that visits each vertex exactly one.

ln I Insights on Discrete Structure


-----------------::-:~;:::;.::.m~-
lnslghts on Discrete Structure 1173
etroit - saginaw - Grand Rapids _ T0 I d
IInportance
, D •
Detroit - 646
e o - kalamazoo .
-
Variety of scheduling
application can be .solved as
a etroit - Grand Rapids - saginaw _ T0 IedO
. salesman problem. D - kaJ~m .....~
trave1ng
l • Detroit - 670 -•-...vu -

Examples: . Detroit - GrandRapids - Toledo _ sagina


Ordering drill position on a drill press. • Detroit - 728 w - kalamazoo -

School bus routing sagioaw Tree as a Directed Graph_ _ _ _ _ __


4.11:__.....:.::.~----_!;_

rree
· I undirected simple graph WI·th no simple
A tree is· a connected •
circuit. A tree ts a partJcu ar type of graph.
Properties
56
I. . There is a unique simple path between any 2 of its vertices.
2. No loops
Kalamazo
13 Tolendo 3. No multiple edges
Route
Detroit, Toledo, Grand - Rapids - saginaw - kala - mazoo .
For example:
• a a
Detroit 610
Detroit Toledo - Grand Rapids - kalamazoo - saginav · b

Detroit 546
d
Detroit Toledo - Grand Rapids - kalamazoo - saginaw - C
• C
Grand - Raphids - Detroit 588
Detroit - Toledo - kalamazoo - Grand Rapids - .saginaw · e

Detroit458 Fig: G l Fig: G2
• Detroit - Toledo - saginaw - kalamazoo - Grand Rapids·
. . G l : It is tree because it is connected graph with no simple
Detroit 540 c1rcu1t.
• Detroit - Toledo - saginaw - Grand Rapids - kalarnazoo .
G2: It is not a free because there is a cycle a, b, e, d, a
Detroit- 504 b f
• Detroit - saginaw - Tolede - Grand Rapids - kalarnazOO ·
Detroit - 598
• Detroit - saginaw - Toledo - kalamazoo - Grand Rapids · e
Detroit - 576 .
a g
• Detroit - saginaw - kalamazoo - Toledo - Grand Rapids·
Fig: G3
·Detroit - 682
'------..::...__ _ _ _ _-:--:-----=-~-;-;:;;---
---:;:;;--;-:=;=:-:--~------~
174 I Insights on Discrete Structure 1nsIghts on Discrete Structure I 175
An undirected graph having no simple circu!t and is not • In this scenario v is c 11
.. . a ed child of u
connected is called forest. The forest has each of its connected Vertices with same parents are called·

components an tree G3 displays a forest. All the vertices that . Siblings
• . . appear 1n th
Theorem 1: vertex v m T, mcluding root are called
e path from root to some
An undirected is a tree if and only if there is a unique simple
• The descendents of a
. - vertex v ·ancestors of v·
path between any two of its vertices. as their ancestor. are those vertices that have V

Proof:
Assume that T is a tree. Since T is a tree. It is a connected
. All th~ vertices that have· ch'ldr
(root IS also an internal v~ ~n are called internal vertices
simple graph with no simple circuits. Let x and Y be two vertices of vertices. x if the tree has more than one
T. We know that every connected graph has a simple path between a
every pair of vertices. So, there is a simple path from x to y. This For example:
path must be unique because, if the path between x and y is not
unique then there is another path between x and Y that uses edges
different from the path, then reversing the path i.e, going to from x
to y from first path and going from y to x through second path
forms a circuit. This is a contradiction that is a tree. Hence, there is f
a unique simple path between any two vertices of a tree. e
Parent : b is parent off and g. g
Rooted (Directed) Tree Child : g and fare children of b
In many applications of trees, a particular vertex of a tree is Siblings: f and g are siblings. Y
designated as the root. A rooted tree is a tree in which one vertex Fig.: Tree
Ancestors : Ancestors of g are b a
has been designated as the root and every edge is directed away D , .
L escendents : Descendents of b .. f,g, y
from the root. We can change an unrooted true into a rooted by
choosing any vertex as the root. The tree in which root is defined eaf: Vertices with no children (y, g,e, d)
produces a directed graph. Intemal vertices : a, b, c, f

a C f th . . ·· Subgraphs cons1stmg
Sub. tree · · of V and its descentants and
· err mc1dent edges
b
Subtree rooted at b:
b
f
C
d

e a b
with root c e f
with root f
g
• Roof :Vertex with in degree o.
•• In a rooted tree, 1·r v is
· the
· vertex in T other than root, then
the Pted
dir d Of v is
arent · a vertex of u in T such that there 1·5 y

176
ec e ge from u to v.

I Insights on Discrete Structure


______________________ ,·
.....: ''·
Insights on Discrete Structure 1177
. th from root to v (level of Inductive hypothesis:_Assume that the t .h .
. th of unique pa . .. ree w,t K vertices
Level(ofv)1sleng I fg::::2) K-1 edges, where k 1s positive integer.
• has ,.
fb - l teve o
root :::: 0, level o - '
. mofverttce
. s level (height : 3) Inductive step: Suppose that a tree r has K + 1 .
Height is the max.1mu . vertices and
• th at y is a leaf of T. Removmg .
vertex V and the . d
associate edge
m-ary trees .f every internal vertex has no from T produces a tree T 1 with K ~ertices, since the resulting graph
• A rooted tree is called m-ary , is still connected and has no simple circuit. By the induction
more than m children. I hYPothesis, Tl has k-1 edges. Hence T has K edges since it has one
. full ary if every internal vertex has exact y m
It 1s m- more edge than the edge connecting V to its parent.

children.
A 2-ary tree is called a binary tree .
Theorem 2:
• b A full m-ary tree with i-internaJ vertices contains n = mi
b
+ 1 vertices.
A level(depth) of a vertex v in a rooted tree is the length of
the uniqu·e path form the root to vertex. The level of the root is
g
zero. The height of the rooted tree is the length of the longest path
f
from the root to any vertex. A rooted m-ary tree of height h is
Fig.: Full binary tree Fig.: Fu/13-ary tree balanced if all leaves are at levels h or h-1.
Ordered Rooted Tree For example:
• An rooted tree where the children of each interval .node are
Vertices = 13
ordered.
Internal vertices (i) = 6
• In ordered binary tree, we can define :
Leaves L = 7
o left child, right child
o left subtree, right subtree l3=6x2+1

• For m-ary trees with m>2, we can~ terms like "left m0st", A full m-ary tree with 0

"right most11 etc. 1. n vertices has I = (n-1)/m internal vertices and


Properties of trees: L == ((m-1) * n + 1)/m leaves
Theorems 1: II. I internal vertices has n = m*l + l vertices
A tree with n vertices bas n-1 edges. and L = (m-1)*1 + 1 leaves
Proof: iii. L leaves has n =(m*l-I)/(m-1) vertices and I= (L-f}/
Basis step: When n = l, a tree with n = I vertex has no ~dge. (m-1) internal vertices.
It follows that theorem is true for n = t.

178 I lnsipts on Discrete Structure


________:_____ ~~~~~--
Insights on Discrete Structure 1179
I,
a Applications of trees:
I! • How should items in a list b ·
e stored so th t .
I easily located? For this we u h
,
a an item can be
se t e cone t Of .
trees. · ep bmary search

• What series of decisions should b


. . e made to find b.
with a certam property in a collecf . an o ~ect
? F h. ton of obJects of a certa·
type . or t ts, we use the concepts 0 f d . . m
ec1s1on trees.
• How. should
?
a set of characters be ffi .
e tctency coded by bit
Stnngs. Here, we use the concept 0 fth ' ·
e prefix codes.
Fig: I 4.12 Binary Search Tree
For example: Searching for items in a list is one ofth .
m = 2, n = 13, I = 6, L = 7 from fig (D , . · e most important task
that a nses m computer science. Our pnmary· 1· •
· I=(n-1)/m=(13-l)/2=6 . . goa ts to implement a
searchmg algonthm that finds items efficiently h h ·
1. and L = ((m·- 1)*n + 1)/m = ((2 - 1)* 13 + 1)/2 = 7 . . w en t e items are
totally ordered. This can be accomplished through the used bin
··
ll. n = m*I + 1 = 2!6 + 1 = 13 search tree. - ary
_and L = (m .- 1) *1 = (2 - 1)*6 + 1 = 7
111• n = (m*L- 1)/(m- 1) = (2*7 - 1)/(2 - I)= 13 A binary search tree (BST) is a binary tree in which each
and I= (L-.1)/(m-1) = (7 - 1)/(2- 1) = 6 child of a vertex is designated as a right or left child, no vertex has
The level of a vertex in-a rooted tree is the length of the path more than one right child or left child and each vertex is labeled
from the root to the vertex (level of the root is 0) with key, wh~ch is one of the items. Further more vertices are
The height of the rooted tree is the maximum of the levels of assigned keys so that the key of a vertex is both larger than the keys
vertices (length of the longest path from the root to any vertex). of all vertices in its left sub tree and smaller than keys of all
Balanced Tree: vertices in its right subtree.
A rooted m-31¥ tree of height h is balanced if all leaves are at We use recursive procedure to form a binary search tree for a
levels h or h-1 st
.. li of items. We start with a tree containing just one vertex,
For example namely, the root. The first item in the list is assigned as the key of
the root. To add a new item, first compare it. with the keys of
vertices already in the tree, starting at the root and moving to the
left if the item is less than the key ofrespective vertex if this vertex
has a left child or moving to the right if the item is greater than the
f f g key of the respective vertex if this vertex bas a right child. When
the item is less than respective vertex and this vertex has no left
Balanced Balanced Not Balanced
---:::--;-:=~:--:::--------------
180 I lnsllhts on Discrete- ·structure
------------~--==:-;:~~1-
lnslghts on Discrete Structure I 18l
T
. rt x with this item as its key is inserted as a
child, then a new ve e . . 4,13 Prefix Codes
.ld s· ·1arly when the 11em 1s greater than the Consider a problem using b. .
new left chI . 1m1 '
. d thi·s vertex has no right child. then a new 1t stnng to
respective vertex an . . the English alphabet. We can repre encode the letters f
.th h. •t as ,
·ts key is inserted as a new right child. sent each I o
vertex w1 t 1s I em of length five as there are only 26 1 etter With a bit stri
etters and th ng
For example: of length five. ere are 32 bit strings
Form a BST for the words mathematics, physics. geography, Consider using bit strings 0 f .
different I
zoology, metrology, geology, psychology and chemistry. letters. Letters that occur more fre ength to encode
. • quent IY should be
short bit stnngs. When letters are oded . encoded using
Decision Trees: enc usm .
bits, some method must be used to detenru g varymg number of
Rooted trees can be used to model problems in which a each character start and end. ne where the bits of a
series of decision leads to a solution. For instance, a binary search
tree can be used to locate items based on a series of comparisions, For instance, if we were e od d .
. . nc e e with O ·
where each comparison tell us whether we have located the item or with O1, then the bit string OJ IO Id • a with I and t
cou represent to
whether we should go left or right in a substance. A rooted tree in string OI OI could correspond to eat eat or tae or bit
, tea, eaea or tt.
which each internal vertex corresponds to a decision with a subtree . One way to ensure that no bit strin co
at these vertices for each possible outcome of these vertices for than one sequence of letters is to e od g rresponds to more
nc e Ietters so that th b. .
each possible outcome of the decision is called a decision tree. The for a letter never occurs as th fi e it stnng
e trst part of the bit trin ti
possible solution of the problem correspond to the paths to the letter codes with this property d s g or another
are ca11e prefix codes.
leaves of the rooted tree.
For example:
a:b
a>b a<b Encoding of e as O
word can ' a as 10 and t as I I is a prefix code. A
letters. be recovered from unique bit string .that encodes its
a>c .........._,......, a<c c>b
For example: IO 110 is the encoding of ate.
c>a>b
b>c ch A prefix code can be represented using binary tree where the
b<c a>c la=~ers are the labels of the leaves of tree. The edge ·of tree are
a>b>c a>c>b b>a>c edg el so th at an edge leading to a left child is assigned a o and an
e We ·
left · construct prefix code from any binary tree where the
edge ate h ·
and ac mtemal vertex is labeled by Oand right edge by 1
I
eaves are labeled by characters.
Fig.: A decision tree for sorting three distinct elements

--:1usii21ffll;nsdiigh;;ts;-:o;:n~D~isc=,et=e:-S::tru-ctu-:--,-e------------
Insights on Discrete Structure I 183
.....
1:

A :::: 0.08, B = 0.10, C:::0.12, D==O. I


0 5
0.05 0.10 0. 12 0.15 ' E: :-20,. F::: 0.35
e
A - B C · O 0.35
D E
f initial
0.12 0. 15 0.15 forest
0.20
0.35
h s C D
E F
The tree in the figure represents encoding of e by 0, a by IO t
by 110, m by 1110 and s by 11 l l.
0.18 0.20
For example: 11111011100
sane
0/\I E 0/\1
0.27 0.35

F
Step2

B A
D C
Huffman coding 0.27 0.35
Here is an algorithm that takes input the frequencies of o/\1 0.35
Step3

:(\I
F
symbols in a string and produces as output a prefix code that
D C
encodes the string using fewest possible bits. This algorithm is
called Huftman coding. It is used in data compression. The subject
devoted to reducing no. of bits required to represent information. B A
Procedure
0.38 0.62
F: Forest of n rooted trees. Step4

While F is no a tree.
O~I :~
begin:

Replace the rooted trees T and T' of least weight from F with A D C
I
W (T) ~ W (T') with a tree having a new root that has T as its left
subtree and T' as its right subtree. Label the new edge to T with 0
and new edge to T' with I.
0
Again ~ (T) + W (T') as weight of new tree end.
F
U~ H~ffman coding to encode following symbols with the
frequenCies listed what is the average no. of bits used to encode a
character.
A
-1Mll~;;:::--;~-:-----------
184 Insights on Discrete Structure
lnsl1hts on Discrete Structure I 185
From the graph; we can encode A by 111 , B by 11 0, c by Example: 2
011, D by 010, Eby 10 , and F by 00. a b
C
The average number of bits used to encode a symbol using d
this encoding is
. Pklk (Pk : Probability, lk : length)
e
= 0.08x3 + 0. t0x3 + 0. J2 x3 + 0. J5X3 + o.2x2 + 0.35 x2
= 2.45
4.14 Spanning Tree
a b
Let G be a simple graptt. A spanning tree is a sub graph of G C
d
that is a tree contain~g every vertex of G.
Consider a system of roads in Maine. The only way the roads e
can be kept open in the winter is by frequently plowing them. The
highway department wants to plow the fewest roads so that there
will always be cleared roads connecting any two towns. At least 5
roads must be plowed to ensure that there is a path between any
two towns. Fig (b) represents one such set of roads. Note that the {a, e}
a

~.
subgraph representing these roads in a tree because it. is connected d
and contains six vertices and five edges.
This problem was solved with a connected subgraph with the e •
minimum number of edges containing all vertices of the original
simple graph such a graph must be a tree.
Example: 1
{e, f}
Etha Old Town Etha Old Town
a b C d
Herman
• •
Orono
Banger
Hampden Hampden
e

(a) (b)

Fig(a): Road system and (b) sets ofroads to plow {c, g}


Fig: Producing spannfng tree for Gby removing edges that form ,simple
circuits.
--~~~=-=-=------------------
186 I Insights on Discrete Structure lnslfhts on Oisae1e S1rumn 11.17
Theorem 1: If path goes through all Vert· ·
. . tees of gr h,
A simple graph is connected if and only if it has 1 of this path 1s spannmg tree ap the tree cons· .
' ISttng
spanning tree. If path does not go through .
a11 Vertie
Proof: edges must be added. , es, more vertices and
Firstiy let a simple graph G has a spanning Tree T. T Move back to the next to 1
contains every vertex of G. Therefore, there is a path T between . ast Vertex . h
possible, form a new path starting all th ' tn t e path and if
any two of its vertices. Because T is a subgraph of ?•
there is a . h is Vertex p .
vertices t at were not already visited. If this ca assing through
path in G between any two of its v~rtices. Hence'. G 1s connec~ed. back another vertex in the path that . t n not be done, move
, is woven· b
Now suppose G is connected, If G 1s not a tree, it ~ust co~ta1~ a and try again. •ces ack in the path
simple circuit. Remove an edge from one of those simple circuits.
The resulting graph has one fewer edge but still contains all the
Example: b
b b
vertices of G is connected. a
C
a b C
a b C d b

I I .-!.
b le

e Solution
e f b
f

spanning trees are important in data networking such as IP


multicasting. .

The proof by theorem I gives an algorithm to finding . b a


spanning trees by removing edges from simple circuits. This The edges selected by depth first search of a graph are called
algorithm is insufficient because it requires that simple circuits be free edges.
identified.
All other edges of the graph must connect a vertex to an
We can build spanning tree for a connected simple graph anceStor or descendant of this vertex in the tree. These edges are
using depth first search. called back edges.
For this, b b b
Firstly, We will arbitrarily choose a vertex of the graph as 8 a
root. C
k
Form a path starting at this vertex by successively adding b b
vertices and edges, where each new edges is incident with Jast
vertex in path- and a vertex not already in the path. b

---;;;-;--;::;:;:=-::::-::--~- --------
188 I lnslpts on Discrete Structure
Insights on Discrete Structure I 189
Solution e
. called back tracking Algorithm
Depth first searcb 1s a1s0 ·
·Fs (G· onnected graph with vertices V 1, v2,
Procedure D ·c
···· ······•Vn) rtex V1 visit (V 1) '
T: tree consisting only Of tbe ve
a
Procedure visit (Vertex of G)
for each vertex w a~jacent to and ~ot yet in T.
m
begin, Depth first search in Directed Graphs
add vertex wand edge {v, w} to T visit (w)
In directed graphs, there can be spanmng
. forest.
end. a b C
Depth first search can be used to find paths and circuits in a d
-
graph, can be used to det~nnine the connected components of a
- ~

graph and to find cut vertic,es of a connected graph. . 1 , ,


f g
e h
Breadth-First Search: -
~

--
Choose a root to the vertex from the vertices of the graph.
• '~ ,.
Then, add all edges incident to this vertex. The new vertices h

added at this stage become the vertices at level 1 in a spanning tree.


Arbitrarily order them.
-- J
.
~

k
~

For each vertex at level 1, visited in order, add e~ch edge


incident to this vertex to the tree as long as it doesnot produce a Solution:
simple circuits. a d
a b C
Example: h
C
e f
dr----+---+---Jg . g
k

h J
j M· . .
lllimum spanning trees:
m spann _A minimum spanning tree in a connected weighted graph is a
k
edge tng tree that has the smallest possible sum of weights of its
s.

190 -I Insights on·Oiscrete-strutture Insights on Discrete Structure ·I 191


We will use 2 algorithms for constructing minimum
i
Example
spanning trees. a 2 b 3 . C
l d
Prim's Algorithm ~
3 1
The algorithm was given by Robert Prim in 1957. 2
4 f 9 5
e g 3
To carry Prism's algorithm
Begin by choosing any edge with smallest weight, putting it 4
3
l 4
- h

3
into the spanning tree. 3 l
Successively add to the tree edges of minimum weight that
are incident to a vertex already in the tree and not fonning a simple
I. J k
--,

circuit with those edges already in the tree. Stop when n-1 edges I Fig: II
have been added.
$2000
{b, f}= l
{f, i}=2
San New York
{a, b} =2
{a,e}=3
{i,j} = 3
{f,g}=3
{c, g} = 2
{c, d} = I
{g, h} = 3
{Chicago, Atlanta}= S700 {h, I} =3
{Atlanta, New York}= S800 {k, I} = I
{Chicago, San Fransico}= $1200 24
{San Fransico, Denver}= $900
a 2 b C d
Total $3600
San Fransico SllOO New York -
Chicago 1 2
3
e f 9 g 3 h
I

$900 3
$800 I
3 l
- j
--
k
Denver Atlanta

=~1199':t{~
. .
Ji~•"~.~~;M~~
. ."'
t ~-;;_~
- ~~ =~~------------
Fig.: Minimum Spanning tree
--~-~=
~-
1---
Fig.: minimum spanning tree
Krushal's Algorithm
This algorithm is given by Jospeh Krushal (c)
a b
C
For this algorithm, • I d
Firstly choose an edge in the graph with minimum weight.
.... ...
Successively add edge with minimum weight that do not
form a simple circuit with those edges already choosen. Stop after
e
=I
f II g,
h
ri-1 edges have been selected.
{b, f} • I

For Fig Ilv


a 2 b 3 C d • •j ..
k • l
1 2 5 (d)
e 3 g 3 a
4 f 9 b b C
e 1 d

4
3

j
1
3

k
4
1
3

e

{c,g} =2
f II gr I
h

Sol11don
1
(a) b d
a
.... •
C

(e)
• •j k
e f
• • a 2 b C 1 d
{c, d}= 1

(b)
a


•-
j

b

•k
C

i
l

d

1

e

{a, b} ~ 2 1
f g
r. 1
h

f . h
e• • g.
• • •j •k • I

1
• • • • l
j k
{le, I} =I
194 I lnsishts on Discrete Structure ________;___------=~-=-=::-:-::==-;-;;;;---
1nsIshts on [)lscrete Structure 1195
(h) a
(t) 2 b
C d 3 C
a b ~ 1 d
2
-..
1 ·2
2 f
e g 3
.f g h •
e
• {f, j} =2 • {g, h} =3
2
·- :
h

2 3 1
• -
• j k
j k - I
(i)
a 2 b C
3 1 d
(t)
a 2 b 3 C 1 d
-
1 2
f g
1 2 e 3 h
f g h
• -
e
• {b, c} = 3
• 2 {i, j} = 3
3 3 1
2
1 i.
.. - - I
j k

k

(j)
a 2 b 3 C 1 d
(g)
a 2 b 3 C 1 d

3 1 2
1 2 f g 3 h
e
e
f g h II -
.

• {j, k} = 3 • {a, e} = 3
2
2 3 3 1
3 1 -
• j k
j k Total = 24

-1 ---
minimum spanning tree
196 I lnsipits on Discrete Structure I

Insights on Discrete Structure I 197


Example 1:
. imum spanning tree
Q. Graph given be/ow,find the min
a 18 b
C .
C D
f

E
8 F
17
Fig.: Dualgraph
e Example 2:
4.15 Graph Coloring b
. of a sunp
A colonng . le graph is the assignment
. of a .color to
each vertex of the graph so that no two adJacent vertices are
a
assigned the sm.ie color.
Smallest number of colors must be used instead of just
assigning every region its own color.
A chromatic number of a graph is the least no. of colour a
Map Dual grapu
needed for coloring graph. QJ. What is the chromatic no. ofgraph.
4 color Map Theorem: b e
The chromatic number of a plannar graph is no greater than
four. a
g
It can be shown that any two dimensional map can be
painted using four color in such a way that adjacent regions are C f
different color5.
Chromatic no. must be at least 3 since a, b, c must be
Dual graph assigned different colors

Each map in a plane can be represented•by a graph .Each b Blue e Green


region is i:eJ>resented by a vertex. Edges connect to vertices if the Red Red
regions represented by these _vertices have a common border.Two a g
regions that touch at only one point are not considered adjacent.
Green
C f
198 f ln5'8hts on Discrete Structure
Insights on Discrete Structure I 199
• In a network there is one sou
QN.2 What is the chromatic no. ofthefig(A) . . rce and one sink An
vertex : ca.1ed mtennediate verteX. · Y other
Green Red • Flow conservation : For any inte d'
nne iate vertex total fl
--------"?'-B into X equals to the now out of X • ' ow
A
C Lwev f (w, x)=Lvev f (x, v)
Green
• Sum of flow from the source= Sum 0 ffl .
ow to the smk.
Red
• Saturated flow: The flow along an ed (
.
. .
ge e v, w) 1s said to be
Red saturated 1f f(e)=c(e).
We can color the g E with at ml colors as shown in the
• If f(e~(e), th~ the flow is unsaturated, then residual
graph red and Green. capacity or slack 1s s(e)=c(e)-f(e).
Q.N.3. Find the chromatic no. of a graph. Flow augmenting path
• The edge ei is called forward edge if: is directed t · . t . ·
• OXJ OX, +!
and transportation fl~w from xi to x. ~ 1, it is backward edge
if transportation flow from xi . 1 to x; .
. If a flow f is given by path p:s = x1, XzX\c.i, X\c = t is called a
. flow augmenting path (i)every forward edge of path bas
· excess capacity that is f(e)<c(e). (ii) every backward edge
has f(e)>O.
4.16 Max Flow and Min Cut
Max flow
In network or transport network the flow is the amount of
• commodity (number of car in a road, gallon of oil in pipe, • The flow that achieves the largest possible value is called the
bits of fonnation in channel etc.) transported from one place maximum flow or maximal flow in a network.
to another for an instant of time. • To calculate max flow calculate the unused capacity c(e)-f(e)
The maximum amount of-low is called the capacity of the
• for each forward arc and f( e) in each backward arc.
line arc or edge. • In a f- augmenting path from source to sink, for the forward
• The flow f(e)=f(v, w) and the capacity c(e)=c(v, w) are non- edge increase the flow with the minimum slack(unused
negative real numbers. capacity) followed in the path.
• f(e~e) . • For backward edge in the f- augmenting path from source to
• The unique starting v~x that has in degree =0 is called sink, decrease the flow with the minimum slack.
sources EV fl= min(c(e) - f(e))
• The unique ending vertex rat has out degree =0 is called .-. = f + fl (for forward edge)
sink, tEV
.-. = f - fl (for backward edge)
--------=~~===--~::_,n.:_s-:-lg-:-h-:--ts-:o~n-:D;:lscr~et;:e;St;;.ru~ctu;;;re;illi2to011--

l
200 I Insights on Discrete Structure
l
r The capacity of a cut denoted by (p .
• 15
s-m of the capacities of thos c d' p') _defmed to be the
I d
· · e e ges d1 ted
vertices m set p to the vertices in p'. , rec from the
a 4,11
If the edge is backward edge put th ·
• edge :: 0. e value of the backward
t
A cut is called minimum cut if its .
s • capacity of any other cut of the networ
cakpacity
. not exceed the
In above network,
If p:: {s} and p' = {a, b, c, d, t} then c(p p')- (
b b) = 2 + l = 3. ' :-- c s, a)+ c(s,
Max flow
Here the unused capacity = slack in f- augmenting path s, a, If p:: {s, a} and p'={b, c, d, t} then c(p _
I
+ c(a, d) = l + 3 + 4 = 8. 'p') - c(s, h) + c(a, b)
d, tare
S(s, a)= 2-l = l
S(a, d) = 4-l = l
I I
Similarly,
Table .fior DOSS
p
' ible s-t cut
p'
.
Capacity c(p, p')
S(d, t) = 4-1 = 3 _ {s} {a, b, c,,d, t} 3
The minimum value is 1 in above slack value. So, now add
{s, a} {b, C, d, t} 8
the value 1 in the flow of s, a, d, t. {s, b} {a, c, d, t} 13
f(s, a)= l + l = 2 {s, c} {a, b, d, t} 7 .
f(a, d) = l + l = 2 {s, d} {a, b, c, t} 15
f(d, t) = l + 1 = 2 {s, a, b} {c, d, t} 15
Now s(s, a) = 2-2 = 0. So, there is not necessity for further {s, a, C} {b, d, t} 20
calculation of slack f-augmenting path containing s(s, a) {s, a, d} {b/C, t} 16
edge.(remember for f-augmenting path (c(e)-f(e))>O). 12 ·
{s, b, c} {a,d,t}
Again, in s(s, b) = 1-1 = 0, So, there is no necessity for {s, b, d} 19
{a, C, t}
further calculation of slack in the augmented path containing edge
{s, c, d} {a, b, t} 11
(s, b)
~{s, a, b, c} {d/t} 10
The max flow = flow from source s = 2 + 1 = 3
_j_s, a, b, d} {c, t} 17
Min cut .J.s, a, c, d} {b, t} 12
• In min cut we calculate the capacity by separating the ~ b, c, d} {a, t} 10
vertices into two subsets p and p' ~a, b, c, d} {t} 8
• p contains sonly ors and other vertices which are not in p'. Mm cut= 3
• p' contains t only or t and other vertices which are not in P· Hence, in the above example max flow = min cut= 3.
• If there are 4 vertices other than source and sink, then there
are 24 = 16 s - t cuts. ·
. (. -----------------~--:-:-~--
I lnsl1hts on Discrete Structure 203
---202w11i-;1n:sights:i::i:;:::on:--;Dlsa~::--:-ete:--:Struct::---u-re_ _ _ _ _ _ _ __;.:..-
l
of the graph. So suppose a connected a .
and e edges has a planar embedding 'tbgr ph With v vertices
WI f faces .
b · rtite explam. with figures. If G •is a In a planar embedding of a connected ·
1. Are C1 and C6 1P" ' . h E edges and V vertices,
connected planar s,·mple w,t < 3 V-6. traversed once by each of two different f:ph, ~ch edge is
th exactly twice by one face. s, or Is traversed
where V~ 3, then prove at E - /2076 Baisakh, Back}
So, every edge is traversed exactly twi ·
1 2 boundaries. So the sum of the lengths of th c; by the face
is exactly 2e. Also, in a planar embedd. e ace boundaries
3 . . h at least three Vertices each f:mg of
graph wit . a connected
.
6
least three. ' ace JS of length at
4
5
when v ~ 3, each face boundary is of length t
th1s . at Ieast 3f . Th.1s llI)pJies
. sum 1s · that a 1east three,
• so
In C3 its vertex can not be Partitioned into • two th disjointh 3fS2e
d V2 such that every edge m e grap
subsets VI an th t V 1 to the vertex of set V2 and But f = e ~ v + 2 by Euler's formula, and substituting into
connec~ a vertex from et s;e connected by an edge. So C3 thea00ve gives
no vertlces ~f the same se
3(e - v + 2) S 2e
is not bipartite. .
But in C6 ·1.ts vetex can be partitioned mto two sets VI = e - Jv+ 6S 2e
. an
={1 ,3,5} - ,4,6}• Every edge. of. C6 . connects a
, d V2 -{2 =esJv-6
vertex in VI with a vertex in V2. So, C6 is b1part1te. 2.
Define Binary tree, M-ary tree t111d Spanning tree. Find the
minimal spanning tree from the graph pen below.
/2076 Baisakl,, Bllck/
b 2 e

a
g
Suppose a connected planar graph has v~3 vertices and e
edges. Then we have to prove ~3v- 6
By defmition, a connected graph is planar iff it has a planar
C 5 f
embedding.
rn-ary tree
In graph theory, a planar graph is a graph that can ~e
embedded in the plane, i.e., it can be drawn on the plane m A rooted tree is called m-ary if every internal vertex has no
such a way that its edges intersect only at .their endpoints: ··· more than m children. It is full m-ary if every internal vertex
has exactly m children. A 2-ary tree is called a b_inary tree.
Such a drawing is called a plane graph or planar embeddmg
-
1 lnslpb.on:Discr.ltlil5ttud"'8 rl1209oi:
(2)
b b 2 e
b

a • 3
g •
d

f f g
g f
y
g
C - f

(3)
b 2 e
A minimum spanning tree in a connected weighted graph is a
spanning tree tha~ has the smallest possible sum of weights
of its edges. a • 4 3
We use two algorithms, Prism's algorithm or Krushkal

d
algorithm, for constructing minimum spanning trees. 4
Here we use Prism's algorithm. In this algorithm we begin C f
by choosing any edge with smallest weight, putting it into (4)
the spanning tree. b 2 e
Successively add to the tree edges of minimum weight that
are incident to a vertex already in the tree and not forming a
simple circuit with those edges already in the tree. Stop when a 4
n-1 edges have been added. 5
3 d
b 2 e

C f

The minimal spanrung


· tree from the given graph
a g
3. Use Dy··1cstr" ,s Algonthm
fr • to fi,ul the JengtJr of shortestJHllh
A:; v~rtex_ a to vertex fin the following weighted graph.
. highlight the shortest path/paths ;,. graph. (l0 76
C 5 f Baisakh, Back] ,
(1) b 9 d
b 2 e

a a f
• d•

. 2 e

------------------::---::-
; C

·,·:. ---~~~:-;;:=:=-=-~-------
206 I lnsilhts on Discrete Structure Insights on l)lscrete Structure I 207
f
00 (4)
3(a) 3(a) -12(a,b)
(1) 9 d
b b 9

f 00
a
a f CX)

C 2
2 e e
C
S(a) 7(a,c)
00
5(a)
S(a,b) 7(a, b, c)
12(a,b) (5) l l(a, b, c, e)
(2) 3(a)
l l(a, c, e)
b 9 d
9

00
a f a f 15(a, ci e)
l S(a, b, c, e)

C
2 e
C e
5(a) 9(a,b)
S(a) -7(a,c)
5(~b) 5(a ,b) 7(a, b, c)
(3)
12(a,b)
3(a) (6) 1 l (a, b, c, e)
b 9 d
3(a) l l~ap.,e)
b. 9
3 3
a f 00
a f 14(a, C, e, d)
14(a, b, c, e, d)
5
C 2 e C 2 e
5(a) 9(a,b) 5(a) 7(a,c)
5(a,b) 5(a, b) 7(a, b, c)

Hence, the shortest path from a to f is:


r -~208MA1fhln~si~lf,ts~on::-;D~lsc=~=ete::-:st=-ru
- ctu-:---re-.- - - - - - ' - - - - - - (a, c, e, d) or (a, b, c, e, d)
---.:...._ _ _ _ _-:---::;::=::-;.::~;or
I Insights on Dfscrete StrUcture I 209-
l
.....

f(e) ~ c(e).
I
/10 76 Baisakh, Back/ •
4. Write short notes on: The unique starting vertex that has in d _ .
a. Regular Graph with example • source s EV egree - O is called
b. Max Flow and Min Cut The~rem The unique ending vertex rat has out degree _ .
• sink, tEV - 0 Is called
Regular Graphs:
h . a graph where each vertex In a network there is one source and one sink. An
In graph theory, a re~ar gra~ is every vertex has the same •
bas the same number of neighbors .1.e., of degree k is called a k-
degree. A regular gra
ph with vernces
b of degree k. Regular grap of
h I •
vertex : ca.ied intermediate vertex. Y other
Flow conservation : For any intennediate vertex, total flow
into x equals to the flow out of x .
regular graph or regular ~p .fy A o-regular graph consists of I
degree at most 2 ~e easy to c ~s• · ph consists of disconnected
disconnected vernces a l-rhegu ar. ~\f disconnected cycles. A 3- I Lwev f (w, x)=Lvev f (x, v)

,s L
edges, and a 2-regular grap ~ons1s
regul: ~b: known cubic graph


Sum of flow from the source = Sum of flow to the sink.
Saturated flow: The flow along an edge e(v, w) is said to be
saturated if f(e) = c(e).
• If f( e) < c(e), then the flow is unsaturated, then residual



• "\\ · V capacity or slack is s(e) = c(e) - f{e).
Flow augmenting path

o-regular graph 1- regular graph 2-regular graph • The edge ei is called forward edge if: is directed to X; to x; +1
and transportation flow from x, to x, ... 1, it is backward edge
if transportation flow from xi +1 to x; .
• If a flow f is given by path p:s = x i. x2, Xt.,. Xt =tis called a
flow augmenting path (i) every forward edge of path has
excess capacity that is f{e) < c(e). (ii) every backward edge
has f{e)>O .

3-regular graph Max flow


Max flow and Min cut
• The flow that achieves the largest possible value is called the
• In network or transport network the flow is the amount of maximum flow or maximal flow in a network.
commodity (nwnber of car in a road, gallon of oil in pipe, • To calculate max flow calculate the unused capacity c(e)-f(e)
bits of fonnation in channel etc.) transported from one place for each forward arc and f(e) in each backward arc.
to another for an instant of time. ••
In a f- augmenting path from source to sink, for the forward
• The maximum amount of-low is called the capacity of the edge increase the flow •with the minimum slack(unused
line arc or edge. capacity) followed in the path.
• The flow f(e) = f(v, w) and the capacity c(e) = c(V, w) are I•
1 F to
_or backward edge in the f- augm.e~ting path from source

1 210
non-negative real numbers.

I lnsilllts on Discrete Structure '1-----


1 sink, decrease the flow with the ID1rumum slack. • ·

Insights on
f)iscrete Structure I 21l

l
• P contains
.
sonly ors and other vertices wh· h .
ic are not ID p'.
• P' contams t only or t and other vertices which are not ID
.
p
fl.= min(c(e)-f(e))
If there are 4 vertices other than source and sink, th ·
f'4' = f + fl. (for forward edge) • are 24 = 16 s-t cuts. en there
f'4' = f - fl. ( for backward edge)
The capacity of a cut denoted by c(p, p') is defined t be
a 4, 11
d • •• f
s-m of t he capaett1es o those edges directed fr
o the
. set p to t he vertices
vertices m . m . p'. om the

• If the edge is backward edge put the value of the backward


s
edge= 0.

• A cut is called minimum cut if its capacity not exceed the


b 5, 11 C capacity of any other cut of the network.
In above network,
M~&w · th
Ifp = {s} and p'={a, b, c, d, t} then c(p, p') = c(s, a) + c(s, b)
acity = slack in f- augmentmg pa s, a,
Here the unused cap = 2 + I = 3.
d, tare
If p = {s, a} and p' = {b, c, d, t} then c(p, p') = c(s, b}+ c(a,
S(s, a)= 2 -1 = l b) + c(a, ~)=I+ 3 + 4 = 8. .
S(a, d) = 4 - l = l Similarly,
S(d, t) = 4 - l = 3 T~ble for possible H cut
The minimum value is 1 in above slack value. So, n?w add p p' Capacity c(p, p')
the value 1 in the flow of s, a, d. t. {s} {a, b, c,,d, t} 3
f(s, a)= I+ I= 2 {s, a} {b, c, d, t} 8
f{a, d) =I+ 1 = 2 {s, b} {a, C, d, t} 13
f{d, t) = l +I= 2 {s, c} {a, b, d, t} 7
Now s(s a) = 2-2 = 0. So, there is not necessity for further {s, d}
- {a, b, c, t} 15
calculation of slack f-augmenting path containing s(s, a)
~
{s, a, b} {c, d, t} 15
edge.(remember for f-augmenting path (c(e)-f{e))>O). ·
· for {s, a, c} {b, d, t} 20
J\gain, _in s(s, b) = 1-1 = 0, So, there. js no necesst~ ·n
~


further calculation of slack in the augmented path contauu g
edge (s, b)
-- {s,,a, d}
{s, b, c}
{b/C, t}
{a, d, t}
16
12
• The max flow = flow from source s = 2 + 1 = 3 ~ s , b,d} 19
{a, c, t}
Min cut ~ s , c, d} {a, b, t} 11
. the
• In min cut we calculate the capacity by separattng {s, a, b, c} {d/t} 10.
(,. vertices into two subsets p and p'
------:::-:-7=-.-::-:---=::---:-----------------
212 I Insights on Discrefe Structure .i
---------------=--==-:~Hl-
lnslpts on Discrete.Structure I 213
l
Using Dijkstra's algorithn, tofi111d ◄
p p' Capacity c(p, p') 6.
path between the vertices a a d the. lengt.'h ofthe sl,
{c, t} 17 n z ,n th orte,,
{s, a, b, d} displayed below./ 071 Magi,/ e Weiglr~d graph
{b, t} 12
{s, a, c, d} C 5 e
{s, b, c, d} {a, t} 10

· {s, a,b,c, d} {t} 8


a
z
Min cut = 3
Hence in the above example max flow = min cut = 3.
' ,.
5. Explain the Euler path and Euler circuit wit~ the helP_ ?fa Solution:
diagram. State the necessary and the sufficient condlti~ns
Here, we can use dijkstra's algorithm t
for Euler circuits and paths. /072 Ashw,nj
path from a to z.
0
ca1culate the shortest
Necessary and Sufficient Conditions for Euler circuits.
C 5 e
• A connected multigrapb bas an Euler circuit if and only if
each of its vertices has even degree.
Proof (why 'only if') a
• Assume the graph has aeuler circuit. Observe_that every time z
the circuit passes through a vertex, it contributes 2 to the
vertex's degree, since the circuit enters via an edge incident"
with this vertex and leaves via another such edge. b d
Necessary and Sufficient Conditions for Euler paths Source= a
A connected multigraph has an Euler path but not an Euler destination = z
circuit if and only if it has exactly two vertices of odd degree.
Step 1
Proof:
• node a is designated as the current node
("only if') assume the graph has an Euler path but not a
circuit. Notice ~t every time the path passes through a vertex, it
• the state of node a is (o, p)
contributes 2 to the degree of the vertex ( 1 when it enters, 1·when • every other node has state ( ~ , t)
it leaves). Obviously the first and the last vertices will have odd
degree and all the other vertices even degree. (co,t) (oo, t)
. - C e
(if): Assume exactly two vertices, u and v have odd degree.
If we connect then two vertices, then every vertex will have even
z
degree. By definition of Eular circuit there is an Eular circuit in
such a graph. _ 7
If we remo~e the added edge {u, v} from this circuit, we will b 5 d
,
get an Eular path .for the original graph. <oo,t) (oo,t)
'
214 I Insights oO Discrete Structure
lnst1hts on Discrete strueture I 215
,...
step 4
Calculate possible adjacent node fr
Step 2 . ce from node 'a'. om node b
Calculate possible adjacent node diStaO Node d can be reached from node b
node b and c can be reach
ed from the current node a. · • Update the distance value dd = { 12 7 + S} _ _
• update distance values fo~ these node
• ' - 12(a, b) ,
Now, the status !able of node b beco
• • mes pennanent
di,= min { 00 ' o+ 7} = 7(a)
• • Now, between the node d and nod
. e e, node e has
s the
de= min { oo. 0 + 6} = 6(a) smallest distance value,
• and c changes to permanent, so, its
now, among thenode b · . The status label of node e changes to pe
• state is (6, p) while the status of b remaUl temporary. • .
of d remains temporary.
nnanent whil ta
' es tus
Node c becomes the current node.
• • Node e becomes the current node.
(6,p) (oo,t) ( 6 ,P) (11,t)
(oo,t) {6,t)
5 e C 5 e
C
(oo,t)
(O,p) ( O,p ) (oo,t)
z
a. a

b 5 d
(oo,t) (7,t) (oo,t) b 5 d
Step3
Calculate possible adjacent node from node c.
Step 5 (7,p) (12,t)

• Node d and e can be reached from the current node c Calculate possible adjacent node from node e
• update d and z can be reached from node e
• Update distance values these nodes
d.t=min{l2, 11 +3} = 12(a, c)
• <Li= min{ oo,6 + 6} = 12(a, c)
dz= min{oo, 11 + 6} = 17(a, c, e)
de= min{oo,6 + 5} = l l(a, c)
• • The status of node d changes to permanent.
(6, p) (11,t)
(6,p) (11,t)
C 5 e
C 5 e
(oo,t)
(O,p) (oo,t)
(O,p)
a z!
a z

5 d
.b
(7,t) (12,t) b 5 d
(7,p) (12,p

216 _I Insights on Discrete Struciure


--. - - - - - -- ----=:=::~~ctu;;, . illl2!1117,---
Insights on Discrete Stru re
~
Step 6: Draw the figure for the co,,, l .
• The next possible adjacent node from node d os node z.
8.
the cycle graph with 5 ven/'x
(5). What is the chromatic n
th
7 ~""!"ite
grt1pl, lc3
is IS usuQJ,-. "- •4 """
• Update the distance value • · h ""'ber 0 r ,,_
bipartite grap k3,4 and the c l
.,, Nt:lloted by
'J tne drt1-, c
11
= 16(a, c.d) YCegraplrcS? o-pfete
• d2 =min {l7,12 + 4}
Blue
I 2 BIUe
{07J Mt1o1,,
., "
• Hence the shortest path using dij ktrn ·s algorithm is= 16(a. c, 3 Blue
d, z) (6,p) (ll .t)

C 5 e
(16.p)
(0,p)
a z

b 5 d
Red 4
(7.p (12,p) 6 Red
Red 7
The iterations of dijkstra•s atgorithm are aescnoed is the following Red
Fig: BipartJt.e graph lc3,f
table.
s L(a) L(b) L(c) L(d) L(e) L(z) Blue
Initial 0 00 00 00 00 00

{a} 0 7 6 00 00 00 Blue
5 2 Green
{a, c} 12 11 00

{a, c, d} 16
{a, c, d, z} 16 Blue ...__ _...J Red
4 3
7. In II round robin tollTIUUllffll the tigers beat the blue jays. C.
- Ftg2:cS
The tigers beat tire C11Tduuds, the tigers be.at the orioles, the
bb,e jays beat tM oriola, and the cardinals beat the The chromatic number of complete bipartite graph k3,4 is
orioles. Moul this 011tco111e with a directed graph.{071 two
Maghj .
The chromatic number of cycle. graph c5 is four.
Tiger 9
Blue Jays • .State necessary and sufficient contlinons for niler circuits
and paths. /071 MgllJ
Solution:

Necessary and Sufficient Conditions for Euler tlrcuits.


Orioles Cardinals • A connected multigrnph has an Euler circuit if and only if
each of its vertjces has even degree.
218 I, lnsiprts on Discrete Structure Proof (why ' only ir)
_______, _ _:____:___:___ _ _-=--=-;::::;.::-i-;;L!-
lnsl,tlts on Dfscrtte Structure I 219
.. d
r •
Assume the graph bas aeuler circuit. Observe that every time
the circuit passes through a vertex, it contributes 2 to the
vertex's degree, since the circuit enters via an edge incident
J{arnUtonian circuit:
• A circuit in a. graph
. G that contains
c~lled a Ham1ltoman circuit in G.
a
.
every_vertex of G is

with this vertex and leaves via another such edge.


Necessary and Sufficient Conditions for Euler paths
• A connected multigraph bas an Euler path but not an Euler e
circuit if and only if it has exactly two vertices of odd
degree.
d
Proof:
("only if') assume the graph has an Euler path but not a
Fig 2: Hamiltonian drcult a, b,c,d,e,
circuit. Notice that every time the path passes through a
vertex, it contributes 2 to the degree of the vertex ( 1 when it b. Max flow and min cut theorem
enters, l when it leaves). Obviously the first and the last Max flow theorem:
vertices will have odd degree and all the other vertices even • In network or transport network th .
commodity ( number of car . e flow IS the amount of
degree.
(if): assume exactly two vertices, u and v have odd degree. If pipe, bits of information in c~:l r:1'
gallon of oil in
we connect then two vertices, then every vertex will have one place to another for an instant of . .) transported from
• Th . hme.
even degree. By definition of Eular circuit there is an Eular e maximum amount of fl ·
the line or arc or edge. ow is called the capacity of
circuit in such a graph.
If we remove the added edge {u, v} from this circuit, we will • :e flo': that achieves the largest possible value is called
get an eula path for the original graph. · maximum flow or maximal flow m
. a network.
JO. Write short. notes on: {071 Magh} • To calculate max flow calculate the .
f( e) for each forward arc and '1 ) . unusedh capacity c(e)-
a. Hamiltonian path and Hamiltonian circuit • In f. .,e m eac backward arc.
forwa d-augm
ed en~g· path from source to sink, for the
b. Max flow and min cut theorem
( ar ge. mcrease the flow with minimum slack
c. Planar graph
unused capacity) followed in the path
Solution: • For
t .backward
nk, edge m• the f-augementing
· path from source
a. Hamiltonian path: 0 si decrease the flow with the minimum slack
• A path m . a graph G that contain
· every vertex of G is = min {c(e)-fle))
called a Hamiltonian path in G. r- = f + (for forward edge)
a a r- = f - (for backward edge)
Min cut theorem:
• In mm · cut we calculate the capacity by separating
a a ...___ vert'ices mto
· two subsets p and p'.

220 I Insights on Discrete Structure Insights on Discrete 5tn,Cture I 2


21
--
,..
• p contains s only or s and other vertices which are not in
corollary 2:
p'. Jf G is a connected planar ~imple •
degree not exceeding 5 graph the G has a v
• If there are 4 vertices other than source and sink, then . ertex of
there are 24= 16 s-t cuts. corollary 3:
• The capacity of cut denoted by c(p, p' ) is defined to the If a connected planar simple h
·b 3 d · grap haseedg
sum of the capacity of those edge directed from the wit v2: an no circuits of length es and v Vertie
.. , 3, then ~2v-4. es
vertices in set p to the vertices in p'.
Q. Use D,jkstra s algorith,n to ft d 'h
• If the edge is backward edge put the value of the path between the vertices a nd i ~ length of the sho~
backward edge = 0.
an zinth •
display he/ow. e weighted.graph
• A cut is called minimum cut if its capacity not exceed the b 9 d {071 Bhadra J
capacity of any cut of the network.
• In a network; max flow = min cut. a
C. Planar graph: z

A graph is called planar if it can be drawn in the plane


without any edges crossing. Such drawing is called a planar
e
representation of the graph. Solution:
For example,
we use Dijkstras algorithm to calculate the shortest path fro
The planar representation of the graph G 1 is G2. a~z m
a b 9 d

a
z

C e
e b d C Source= a
GI G2
destination =z
Euler's formula
Step 1:
. Let G be a connected planar simple graph with e edges and v
vertices. Let r be the number of regions in a planer representation
• N . .
ode a Is designated as the current node
ofG. then r = e-,v + 2 • The state of node a is (0, p)
Corollary 1: • Every other node has state (a, t)
If ~ is a connected planar simple graph with e edges and v
vertices where v2:J, then ~3v-6.

222 f lnslpts on Discrete Structure


Insights on Discrete Struct\lre I 223
Ii.
d
(oo, C)
b 9
(oo, t)
d
• Now. among the node c and d
value
c has th
e smallest d'
lSfanee
-
(O,p)p ( ,1) • The status label of node c chan
. ges to perrnane .
IS (3, p). · nt, so Its State
a z
• node c become the current node.

(1, p)b
(oo.t)b 5 (a:i, c) (10, t)b
C
C
b 9
d
(O,p)p
Step 2:
• Node b and c can be reached from the current node a. a (a:i,t)b

• Update distance values for these node. z


di,= min {a,O+ I}= l(a)
de= min {a 0 + 4} =4(a) (3,p) 5
(co,r)
Step 4:
• Now, among the node b and c, node b has the smallest C e
distance value • Node d and e can be reached from nod
ec.
• The status label of node b changes to permanent so • Update the distance values
state is (I, p) while the status of c remains temporary.
~= min { I0,3 + 6} = 9(a, b, c)
• Node b becomes the current node.
de= min{a, 3 + 5} = 8(a, b, c)
(l,p)
(co,5) • Nolw, among node d and e, node e has smallest distance
9 va ue.
b d
(0,p)p
I
( oo,t)
• ~~e status lable of e changes to permanent So, its state is (8,
6
a
z • Node e become the current node.
4 (1, p)
(9, t)
(4,t) 5 (oo, t) b 9
C e d
(O,p)p
Step 3: (oo.t)b
a
• Node c and d c.µi be reached from the current node b. b
z
• update distance values for these node.
rlci= min{a, I + 9} = IO(a, b)
(3,p) 5
<ic=min{4, I +2} =3(a,b) (8,p)
C
224 I lnsflhts on Discrete Structure e

lnsl1hts on Discrete Structure I 225


1
• 11•
Draw the figure for the complet
e graph w· h
Step 5: this is usually denoted by kt,) D ~ u 6 Vertices (
• Node d and z can be reached from node e. coloring and the chromatic nu~b e ne the tern, Paplt
. h h . er of a 6"aplt
What ,s t e c romattc number of the coloring.
• Update the distance values k6?/071 Bhadra/ co,np/ete graph
cl.! = min{9,8 + 3} = 9(a, b, c) a b
dz= min{a ,8 + 2} = lO(a, b, c, e)
• Node z can be reached from node d.
f
• Node d becomes the current node C

(1,p) (9,p)

9 . d
b e d
(O,p)p (10,p) Fig: complete graph with 6 vertJces(lc J
6
a z Graph coloring:
A coloring of a simple graph is the as .
sigrunent of a color to
each vertex of the graph so that no two ad" .
(3,p) 5 (8,p) assigned the same color. ~acent vertices are
C
e Smallest number of the colors must be used . .
Step 6: · • . . mstead of Just
assignmg every region its own color.
• Node e and z can be reached from node d
Red
• Update the distance value a
Blue
de= min{8, 9 + 3} = 8(a, b, c) b
dz= m in{lO, 9 + 8} = IO(a, b, c, e)
Hence, the shortest path using dijkstra's algorithm is lO(a, b,
c, e, z)
(I,p) (9,p)
Red
b 9 d
d Blue c
(0,p)p (10,p)
Chromatic number:
a z 1
A chr ·
omattc number of a graph is the . least no. of color
• needed for co!oring graph.

(3,p) (8,p) Chromatic number of the complete graph ~


C
e

226 I Insights on Discrete Structure Insights on Discrete Structure I 227

d
l
r
C

Blue
The highway department want .
Red
that there wiJI always be clearsdto plow the fewest road
a b e roads co . s so
towns. At least 5 roads must be 1 . nnecting any tw
p owed to ens o :
a path between any two towns. p·ig(b) rep ure that the~e is
· ,
Green f of roads. Note that the sub graph . r~sents one such set j
c Black b . . representmg th ,
tree ecause 1t 1s connected and . . ese roads is a
I edges.
This problem was solved with a
contams six ·
vertices and five

Yellow e d White . . connected sub h


the m1mmum number of edges co ta. . &rap with
original simple graph such a graphn mmg all vertices of the
Chromatic number of the complete graph k6 = 6 must be a tree.
12. Explain the Hamiltonian path and Hamiltonian circuit
• with the help of a diagram. State the necessary and
sufficient conditions for Euler circuits and paths. How is
Hennan
Euler circuit different from the Hamiltonian circuit? [071
Bhadraj
Hamiltonian path and Hamilt(!nian ciruit with the help of Hampden
Hampden
a diagram [2071 Magh Q.ll(a))
Necessary and sufficient conditions for Euler circuits and Fig(a)
Fig(b)
paths. (2071 Magh Q.10) Fig(a): Road system
How is Euler circuit different from Hamiltonian circuits Fig(b): Sets of road to plow
For Euler circuit, a circuit c in a graph G must contain every
b. Cut sets and cut vertices
edge of G. with no edge repetition.
Solution:
But for Hamiltonian circuits, a circuit in a graph G contain
every vertex of G. . Cut sets:
13. Write short notes on: A set of edges of a h h' . ·
d· grap w 1ch, if removed or cut,
a. Spanning tree isconnects the graph · ~ d'
. . . , i.e. ,onn a 1sconnected graph. A
b. Cursets and cut vertices 0
: : \ .•s said to be disconnected if it is not connected i.e. if
c. Application oftrees'/071 Bhadraj x1st two nodes in G such that no path in G has those
Solution: nodes as endpoints.
c.
a) Spanning tree: AppUcation of trees:
Let G be a simple graph. A spanning tree is a sub graph of G Tree a s ·
. '. pec1a1 type of connected simple graph with no
that is a tree containing every vertex of G. circuit is im . ·
' portant m both theory and application. Many
Consider system of roads in Maine. The only way the roads po':erful algorithms in computer science and software
eng1 · ·
can be kept open in the winter is by frequently plowing them. neenng are tree based algorithms.

1 .• 228 I Insights on Discrete Structure


Insights on Discrete Structure I 229

---------•-----
How should items in a list be stored so that an item can be
easily IOcated? For this, we Use the concept of binary search
tree.

What series of decisions should be made to find an objec,


. With a Certain Property in a collection of objects of a cena;,,
tyPe? For this we use the concept of decision trees.
How should a set of charactens be efficiency Coded by b;t
stri~gs? llere, we use the concept of prefix codes .

•••

230 I Insights on Discrete Structure


I
1111

You might also like