Unit5 DIS
Unit5 DIS
Unit5 DIS
Noida
Unit: 5
Discrete Structure
ANAMIKA TIWARI
B. Tech 3rd Sem Assistant Professor
B.Tech AIML
Noida Institute of Engineering and Technology, Greater Noida
Introduction
ANAMIKA TIWARI
1. Discrete Structures are useful in studying and describing objects and problems in branches
of computer science such as computer algorithms, programming languages.
2. Computer implementations are significant in applying ideas from discrete mathematics to real-
world problems, such as in operations research.
3. It is a very good tool for improving reasoning and problem-solving capabilities.
4. Discrete mathematics is used to include theoretical computer science, which is relevant to
computing.
5. Discrete structures in computer science with the help of process algebras.
• The subject enhances one’s ability to develop logical thinking and ability to
problem solving.
CO1 Apply the basic principles of sets, relations & functions and K3
mathematical induction in computer science & engineering related
problems
CO2 Understand the algebraic structures and its properties to solve K2
complex problems
CO3 Describe lattices and its types and apply Boolean algebra to simplify K2,K3
digital circuit.
CO4 Infer the validity of statements and construct proofs using predicate K3,K5
logic formulas.
CO5 Design and use the non-linear data structure
ANAMIKA TIWARI like tree and graphs to K3,K6
Discrete
07/02/24 10
Structures
solve real world problems. Unit 5
Content
• Course Objective
• Course Outcome
• CO-PO Mapping
• Syllabus
• Prerequisite and Recap
• Graph and digraph
• Incidence and adjacency matrix
• Isomorphism
• Eulerian path and circuits in graphs
• Hamiltonian path and circuits
• Trees
• Four color theorem
• Planar graphs
• Clique number
• Chromatic number
• Video links
• Daily Quiz
• Weekly Assignment
• MCQ
• Old Question papers
• Expected Question for University Exam
• Summary
• References.
CO1 Apply the basic principles of sets, relations & functions and K3
mathematical induction in computer science & engineering
related problems
CO2 Understand the algebraic structures and its properties to solve K2
complex problems
CO3 Describe lattices and its types and apply Boolean algebra to K2,K3
simplify digital circuit.
CO4 Infer the validity of statements and construct proofs using K3,K5
predicate logic formulas.
CO5 Design and use the non-linear data structure like tree and K3,K6
07/02/24 graphs to solve real world
ANAMIKA problems.
TIWARI Discrete Structures Unit 5 14
Program
Program Outcome
Outcomes
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
ACSE0306.1
2 2 3 3 2 2 - - 2 1 - 3
ACSE0306.2
1 3 2 3 2 2 - 1 1 1 2 2
ACSE0306.3
2 2 3 2 2 2 - 2 2 1 2 3
ACSE0306.4
2 2 2 3 2 2 - 2 2 1 1 3
ACSE306.5
3 2 2 2 2 2 - 2 1 1 1 2
Average 2 2.2 2.4 2.6 2 2 - 1.4 1.6 1 1.2 2.6
• https://www.youtube.com/watch?v=Dsi7x-A89Mw&list=PL0862D1A94725
2D20&index=28
• https://www.youtube.com/watch?
v=74l6t4_4pDg&list=PL0862D1A947252D20&index=29
• https://www.youtube.com/watch?
v=4d2XEn1j_q4&list=PL0862D1A947252D20&index=30
• Tree
• Binary Tree
• Tree Traversal
• Binary Search Tree
• Graphs
• Types of Graph
• Graph coloring
• Define how Tree and graphs will be serve as models for many
standard problems.
• How Graph theory will be used in Computer networks to minimize
the cost and time of delivery of data.
• To distinguish between two chemical compounds with the same
molecular formula but different structures.
• To solve shortest path problems between cities.
• To schedule exams and assign channels to television stations.
07/02/24 27
ANAMIKA TIWARI Discrete Structures Unit 5
Trees (CO5)
A tree whose elements have at most 2 children is called a binary tree. Since each
element in a binary tree can have only 2 children, we typically name them the left
and right child.
•In-order Traversal
•Pre-order Traversal
•Post-order Traversal
B, D, A, G, E, C, H, F, I.
A, B, D, C, E, G, F, H, I
D, B, G, E, H, I, F, C, A.
A node's left child must have a value less than its parent's value and the node's
right child must have a value greater than its parent value.
The basic operations that can be performed on a binary search tree data structure, are the
following −
• Representation:
Graph G =(V, E) consists set of vertices denoted by V, or by V(G) and set of
edges E, or E(G)
• In the above Graph, the set of vertices V = {0,1,2,3,4} and the set of edges E =
{01, 12, 23, 34, 04, 14, 13}.
u v
Loop: A loop is an edge whose endpoints are equal i.e., an edge joining
a vertex to it self is called a loop. Represented as {u, u} = {u}
u
Multiple Edges: Two or more edges joining the same pair of vertices
Representation Example: For V = {u, v, w} , E = { {u, w}, {u, w}, (u,v) }, deg
(u) = 2, deg (v) = 1, deg (w) = 1, deg (k) = 0, w and v are pendant , k is
isolated
Null Graph
A graph having no edges is called a Null Graph.
Trivial Graph
A graph with only one vertex is called a Trivial Graph.
Non-Directed Graph
A non-directed graph contains edges but the edges are not
directed ones.
07/02/24 ANAMIKA TIWARI Discrete Structures Unit 5 48
Simple graph – special case(CO 5)
Directed Graph
In a directed graph, each edge has a direction.
Simple Graph
A graph with no loops and no parallel edges is called a simple graph.
•The maximum number of edges possible in a simple graph with ‘n’ vertices
is nC2 where nC2 = n(n – 1)/2.
•The number of simple graphs possible with ‘n’ vertices = 2nc2 = 2n(n-1)/2.
Disconnected Graph
A graph G is disconnected, if it does not contain at least two connected
vertices.
A simple graph with ‘n’ mutual vertices is called a complete graph and it
is denoted by ‘Kn’. In the graph, a vertex should have edges with all other
vertices, then it called a complete graph.
Acyclic Graph
A graph with no cycles is called an acyclic graph.
A wheel graph is obtained from a cycle graph Cn-1 by adding a new vertex.
That new vertex is called a Hub which is connected to all the vertices of
Cn.
Notation − Wn
No. of edges in Wn = No. of edges from hub to all other vertices +
No. of edges from all other nodes in cycle graph without a hub.
= (n–1) + (n–1)
= 2(n–1)
A bipartite graph, also called a bi-graph, is a set of graph vertices decomposed into
two disjoint sets such that no two graph vertices within the same set are adjacent.
A bipartite graph is a special case of a k-partite graph with k=2 .
The illustration above shows some bipartite graphs, with vertices in each graph
colored based on to which of the two disjoint sets they belong.
Bipartite graphs are equivalent to two-colorable graphs. All acyclic graphs are
bipartite. A cyclic graph is bipartite iff all its cycles are of even length
|V(G2)| = n
u e1 e2 e3
e1 e2 v 1 0 1
u 1 1 0
v w
e3 w 0 1 1
v u w
v w v 0 1 1
u 1 0 1
w 1 1 0
v u w
u v 0 1 0
u 0 0 1
v w w 1 0 0
u v,w
v w v w, u
w u,v
• If G1 ≡ G2 then −
|V(G1)| = |V(G2)|
|E(G1)| = |E(G2)|
• Degree sequences of G1 and G2 are same.
If the vertices {V1, V2, .. Vk} form a cycle of length K in G1, then the vertices {f(V1),
f(V2),… f(Vk)} should form a cycle of length K in G2.
• All the above conditions are necessary for the graphs G 1 and G2 to be
isomorphic, but not sufficient to prove that the graphs are isomorphic.
• (G1 ≡ G2) if and only if (G1− ≡ G2−) where G1 and G2 are simple graphs.
• (G1 ≡ G2) if the adjacency matrices of G1 and G2 are same.
• (G1 ≡ G2) if and only if the corresponding subgraphs of G 1 and G2 (obtained by
deleting some vertices in G1 and their images in graph G 2) are isomorphic.
07/02/24 ANAMIKA TIWARI Discrete Structures Unit 5 64
Graph - Isomorphism(CO5)
•In the graph G3, vertex ‘w’ has only degree 3, whereas all the other graph
vertices has degree 2. Hence G3 not isomorphic to G 1 or G2.
• Representation example
3-chromatic
7. A graph with no edges is known as empty graph. Empty graph is also known as... ?
a) Trivial graph
b) Regular graph
c) Bipartite graph
d) None of these
Q5. If a simple graph G, contains n vertices and m edges, the number of edges in the Graph
G'(Complement of G) is ___________
a) (n*n-n-2*m)/2 b)(n*n+n+2*m)/2
c) (n*n-n-2*m)/2 d) (n*n n+2*m)/2
Q6. Which of the following properties does a simple graph not hold?
a) Must be connected b) Must be unweighted
c) Must have no loops or multiple edges d) Must have no multiple edges
Q7. What is the maximum number of edges in a bipartite graph having 10 vertices?
a) 24 b) 21
c) 25 d) 16
Q13. The time complexity to find a Eulerian path in a graph of vertex V and edge E is
_____________
a) O(V2)
b) O(V+E-1)
c) O(V+E)
d) O(E+1)
Q15. What is the minimum height for a binary search tree with 60 nodes?
a) 1
b) 3
c) 4
d) 2
Q16. For the expression (7-(4*5))+(9/3) which of the following is the post order tree traversal?
a) *745-93/+
b) 93/+745*-
c) 745*-93/+
d) 74*+593/-
Q1 Construct a binary tree from the given two Travels (IGDTUW, 2020)
In order 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
Post order 1, 4, 3, 2, 6, 8, 9, 11, 10, 7, 5
Q2 Define Hamiltonian graph with suitable example. (Anna Univ, 2017)
Q3 Define planar graph. Prove that for any connected planar graph, v – e+ r = 2 Where v, e, r
is the number of vertices, edges, and regions of the graph respectively. (AKTU, 2017)
Q4. What are different ways to represent a graph. Define Euler circuit and Euler graph. Give
necessary and sufficient conditions for Euler circuits and paths. (KTU,2017)
Q5. For the expression (7-(4*5))+(9/3) which of the following is the post order tree traversal?
Q6. What are application of a Depth First Search traversal ? (Anna Univ, 2017)
Q7. What is the Worst case complexity of Breadth First Search traversal ? (NIET Autonomous,
2021)
Q8. What are the applications of Breadth First Search traversal? (KTU, 2017)
For more Previous year Question papers:
https://drive.google.com/drive/folders/1xmt08wjuxu71WAmO9Gxj2iDQ0lQf-so1
• Tree Terminology
• A tree is a hierarchical data structure defined as a collection of nodes. Nodes represent value and nodes are
connected by edges. A tree has the following properties:
• The tree has one node called root. The tree originates from this, and hence it does not have any parent.
• Each node has one parent only but can have multiple children.
• Each node is connected to its children via edge.
• Binary Tree: In a Binary tree, every node can have at most 2 children, left and right. In diagram below, B &
D are left children and C, E & F are right children.
• Balanced Tree: If the height of the left and right subtree at any node differs at most by 1, then the tree is
called a balanced tree.
• GRAPH- In discrete mathematics, a graph is a collection of points, called vertices, and lines between
those points, called edges.
•The concept of graphs in graph theory stands up on some basic terms such
as point, line, vertex, edge, degree of vertices, properties of graphs, etc.
•Graph theory has several application in real world.
•Graph theory used in Computer networks to minimize the cost and time of
delivery of data.
•To distinguish between two chemical compounds with the same molecular
formula but different structures.
• To solve shortest path problems between cities.
•To schedule exams and assign channels to television stations.