SlideShare a Scribd company logo
Analysis and Design of Algorithms
Graph Algorithms
Analysis and Design of Algorithms
Graph
Directed vs Undirected Graph
Acyclic vs Cyclic Graph
Backedge
Search vs Traversal
Breadth First Traversal
Depth First Traversal
Detect Cycle in a Directed Graph
Analysis and Design of Algorithms
 Graph data structure consists of a
finite set of vertices or nodes. The
interconnected objects are
represented by points termed as
vertices, and the links that connect
the vertices are called edges.
A
B C
D E
F
Node or Vertices
Edge
Analysis and Design of Algorithms
 Vertex: Each node of the graph is
represented as a vertex.
 V={A,B,C,D,E,F}
 Edge: Edge represents a path
between two vertices or a line
between two vertices.
 E={AB,AC,BD,BE,CE,DE,DF,EF}
A
B C
D E
F
Node or Vertices
Edge
Analysis and Design of Algorithms
A
B C
A
B C
Directed Graph Undirected Graph
Analysis and Design of Algorithms
A
B C
Acyclic Graph Cyclic Graph
A
B C
Analysis and Design of Algorithms
Backedge is an edge that is from node to itself
(selfloop), or one to its ancestor.
A
B
A
Analysis and Design of Algorithms
Search: Look for a given node
Traversal: Always visit all nodes
Analysis and Design of Algorithms
Breadth First Traversal
Analysis and Design of Algorithms
Breadth First Traversal (BFT) algorithm traverses all nodes
on graph in a breadthward motion and uses a queue to
remember to get the next vertex.
Analysis and Design of Algorithms
Layers A
B C
D E
F
Layer1
Layer2
Layer3
Layer4
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print:
A
B C
D E
F
0 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print:
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= A
 Print:
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print: A
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print: A
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print: A
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print: A
A
B C
D E
F
1 1 1 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= B C
 Print: A
A
B C
D E
F
1 1 1 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= C
 Print: A B
A
B C
D E
F
1 1 1 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= C
 Print: A B
A
B C
D E
F
1 1 1 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= C
 Print: A B
A
B C
D E
F
1 1 1 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= C
 Print: A B
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= C D E
 Print: A B
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= D E
 Print: A B C
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= D E
 Print: A B C
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= E
 Print: A B C
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= E
 Print: A B C D
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= E
 Print: A B C D
A
B C
D E
F
1 1 1 1 1 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= E
 Print: A B C D
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= E F
 Print: A B C D
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= F
 Print: A B C D E
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= F
 Print: A B C D E
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue= F
 Print: A B C D E
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print: A B C D E
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
 Visited=
 Queue=
 Print: A B C D E F
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
Breadth First on Tree
Analysis and Design of Algorithms
Analysis and Design of Algorithms
 V={0,1,2,3,4,5}
 E={01,02,13,14,24,34,35,45}
0
1 2
3 4
5
Analysis and Design of Algorithms
Analysis and Design of Algorithms
 Another Example:
Analysis and Design of Algorithms
Depth First Traversal
Analysis and Design of Algorithms
Depth First Traversal (DFT) algorithm traverses a graph in
a depthward motion and uses a stack to remember to get
the next vertex to start a search.
Analysis and Design of Algorithms
depthward motion A
B C
D E
F
Analysis and Design of Algorithms
 Visited=
Stack=
 Print:
A
B C
D E
F
0 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
Stack=
 Print:
A
B C
D E
F
0 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
Stack=
 Print:
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
Analysis and Design of Algorithms
 Visited=
Stack=
 Print:
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A
A
B C
D E
F
1 0 0 0 0 0
A B C D E F
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A
A
B C
D E
F
1 1 0 0 0 0
A B C D E F
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A
A
B C
D E
F
1 1 0 0 0 0
A B C D E F
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B
A
B C
D E
F
1 1 0 0 0 0
A B C D E F
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B
A
B C
D E
F
1 1 0 0 0 0
A B C D E F
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B
A
B C
D E
F
1 1 0 1 0 0
A B C D E F
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B
A
B C
D E
F
1 1 0 1 0 0
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D
A
B C
D E
F
1 1 0 1 0 0
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D
A
B C
D E
F
1 1 0 1 0 0
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D
A
B C
D E
F
1 1 0 1 0 0
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D
A
B C
D E
F
1 1 0 1 1 0
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D
A
B C
D E
F
1 1 0 1 1 0
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E
A
B C
D E
F
1 1 0 1 1 0
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E
A
B C
D E
F
1 1 0 1 1 0
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E
A
B C
D E
F
1 1 0 1 1 0
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E
A
B C
D E
F
1 1 0 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E
A
B C
D E
F
1 1 0 1 1 1
A B C D E F
F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F
A
B C
D E
F
1 1 0 1 1 1
A B C D E F
F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F
A
B C
D E
F
1 1 0 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F
A
B C
D E
F
1 1 0 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F
A
B C
D E
F
1 1 0 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
C
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
E
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
A
Analysis and Design of Algorithms
 Visited=
Stack=
 Print: A B D E F C
A
B C
D E
F
1 1 1 1 1 1
A B C D E F
Analysis and Design of Algorithms
Depth First on tree
Analysis and Design of Algorithms
Analysis and Design of Algorithms
 V={0,1,2,3,4,5}
 E={01,02,13,14,24,34,35,45}
0
1 2
3 4
5
Analysis and Design of Algorithms
Analysis and Design of Algorithms
 Another Example:
Analysis and Design of Algorithms
Given a directed graph, check whether the graph
contains a cycle or not. Your function should return
true if the given graph contains at least one cycle,
else return false.
Analysis and Design of Algorithms
Depth First Traversal can be used to detect cycle in a
Graph. There is a cycle in a graph only if there is a
back edge present in the graph.
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
0 0 0 0
A B C D
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
0 0 0 0
A B C D
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 0 0 0
A B C D
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 0 0 0
A B C D
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 0 0 0
A B C D
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 0 0
A B C D
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 0 0
A B C D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 0 0
A B C D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 1 0
A B C D
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 1 0
A B C D
C
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 1 0
A B C D
C
B
A
Analysis and Design of Algorithms
 Visited=
Stack=
A
C
B
D
1 1 1 0
A B C D
C
B
A
Analysis and Design of Algorithms
Graph contains cycle
A
C
B
D
Analysis and Design of Algorithms
Analysis and Design of Algorithms
Analysis and Design of Algorithms
facebook.com/mloey
mohamedloey@gmail.com
twitter.com/mloey
linkedin.com/in/mloey
mloey@fci.bu.edu.eg
mloey.github.io
Analysis and Design of Algorithms
www.YourCompany.com
© 2020 Companyname PowerPoint Business Theme. All Rights Reserved.
THANKS FOR
YOUR TIME

More Related Content

What's hot (20)

Hashing
HashingHashing
Hashing
Amar Jukuntla
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
Rajendra Dangwal
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Heaps
HeapsHeaps
Heaps
Hafiz Atif Amin
 
Brute force method
Brute force methodBrute force method
Brute force method
priyankabhansali217
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
Rezwan Siam
 
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
Saurabh Kumar
 
Linear Search Presentation
Linear Search PresentationLinear Search Presentation
Linear Search Presentation
Markajul Hasnain Alif
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
swapnac12
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
sumitbardhan
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Hinal Lunagariya
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Skip lists (Advance Data structure)
Skip lists (Advance Data structure)Skip lists (Advance Data structure)
Skip lists (Advance Data structure)
Shubham Shukla
 
Red black tree
Red black treeRed black tree
Red black tree
Rajendran
 
Quick sort data structures
Quick sort data structuresQuick sort data structures
Quick sort data structures
chauhankapil
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
Rezwan Siam
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
swapnac12
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
sumitbardhan
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Skip lists (Advance Data structure)
Skip lists (Advance Data structure)Skip lists (Advance Data structure)
Skip lists (Advance Data structure)
Shubham Shukla
 
Red black tree
Red black treeRed black tree
Red black tree
Rajendran
 
Quick sort data structures
Quick sort data structuresQuick sort data structures
Quick sort data structures
chauhankapil
 

Similar to Algorithms Lecture 7: Graph Algorithms (20)

Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
Arvind Krishnaa
 
graph.pptx
graph.pptxgraph.pptx
graph.pptx
hijigaf
 
Data Structures-Non Linear DataStructures-Graphs
Data Structures-Non Linear DataStructures-GraphsData Structures-Non Linear DataStructures-Graphs
Data Structures-Non Linear DataStructures-Graphs
sailaja156145
 
graphs
graphsgraphs
graphs
Mohamed Elsayed
 
Algorithms and data Chapter 3 V Graph.pptx
Algorithms and data Chapter 3 V Graph.pptxAlgorithms and data Chapter 3 V Graph.pptx
Algorithms and data Chapter 3 V Graph.pptx
zerihunnana
 
Graph theory basics
Graph theory basicsGraph theory basics
Graph theory basics
Alexey Tokar
 
lec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.pptlec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.ppt
TalhaFarooqui12
 
Graphs
GraphsGraphs
Graphs
Lakshmi Sarvani Videla
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
Savit Chandra
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
Pre-Cal 40S March 1, 2009
Pre-Cal 40S March 1, 2009Pre-Cal 40S March 1, 2009
Pre-Cal 40S March 1, 2009
Darren Kuropatwa
 
267 4 determinant and cross product-n
267 4 determinant and cross product-n267 4 determinant and cross product-n
267 4 determinant and cross product-n
math260
 
Graphs Basics.pptx
Graphs                        Basics.pptxGraphs                        Basics.pptx
Graphs Basics.pptx
SanGeet25
 
Breadth first search
Breadth first searchBreadth first search
Breadth first search
Sazzad Hossain
 
Graph theory
Graph theory Graph theory
Graph theory
iranian translate
 
Graph
GraphGraph
Graph
Dr Sandeep Kumar Poonia
 
Graph Introduction.ppt
Graph Introduction.pptGraph Introduction.ppt
Graph Introduction.ppt
Faruk Hossen
 
20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers
Computer Science Club
 
IGCSE_Functions.pptx fffffffffffffffffffffffffffffffffffffffffffffffffffffff...
IGCSE_Functions.pptx  fffffffffffffffffffffffffffffffffffffffffffffffffffffff...IGCSE_Functions.pptx  fffffffffffffffffffffffffffffffffffffffffffffffffffffff...
IGCSE_Functions.pptx fffffffffffffffffffffffffffffffffffffffffffffffffffffff...
ssuser1e25bf1
 
18 Basic Graph Algorithms
18 Basic Graph Algorithms18 Basic Graph Algorithms
18 Basic Graph Algorithms
Andres Mendez-Vazquez
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
Arvind Krishnaa
 
graph.pptx
graph.pptxgraph.pptx
graph.pptx
hijigaf
 
Data Structures-Non Linear DataStructures-Graphs
Data Structures-Non Linear DataStructures-GraphsData Structures-Non Linear DataStructures-Graphs
Data Structures-Non Linear DataStructures-Graphs
sailaja156145
 
Algorithms and data Chapter 3 V Graph.pptx
Algorithms and data Chapter 3 V Graph.pptxAlgorithms and data Chapter 3 V Graph.pptx
Algorithms and data Chapter 3 V Graph.pptx
zerihunnana
 
Graph theory basics
Graph theory basicsGraph theory basics
Graph theory basics
Alexey Tokar
 
lec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.pptlec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.ppt
TalhaFarooqui12
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
Savit Chandra
 
267 4 determinant and cross product-n
267 4 determinant and cross product-n267 4 determinant and cross product-n
267 4 determinant and cross product-n
math260
 
Graphs Basics.pptx
Graphs                        Basics.pptxGraphs                        Basics.pptx
Graphs Basics.pptx
SanGeet25
 
Graph Introduction.ppt
Graph Introduction.pptGraph Introduction.ppt
Graph Introduction.ppt
Faruk Hossen
 
20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers20101017 program analysis_for_security_livshits_lecture02_compilers
20101017 program analysis_for_security_livshits_lecture02_compilers
Computer Science Club
 
IGCSE_Functions.pptx fffffffffffffffffffffffffffffffffffffffffffffffffffffff...
IGCSE_Functions.pptx  fffffffffffffffffffffffffffffffffffffffffffffffffffffff...IGCSE_Functions.pptx  fffffffffffffffffffffffffffffffffffffffffffffffffffffff...
IGCSE_Functions.pptx fffffffffffffffffffffffffffffffffffffffffffffffffffffff...
ssuser1e25bf1
 
Ad

More from Mohamed Loey (20)

Lecture 6: Deep Learning Applications
Lecture 6: Deep Learning ApplicationsLecture 6: Deep Learning Applications
Lecture 6: Deep Learning Applications
Mohamed Loey
 
Lecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network ModelsLecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
Lecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning FrameworksLecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Lecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural NetworksLecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural Networks
Mohamed Loey
 
Lecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural NetworksLecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural Networks
Mohamed Loey
 
Lecture 2: Artificial Neural Network
Lecture 2: Artificial Neural NetworkLecture 2: Artificial Neural Network
Lecture 2: Artificial Neural Network
Mohamed Loey
 
Lecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer VisionLecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer Vision
Mohamed Loey
 
Design of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer DiseasesDesign of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer Diseases
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1
Mohamed Loey
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work II
Mohamed Loey
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSA
Mohamed Loey
 
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption StandardComputer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Mohamed Loey
 
Computer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary MaterialComputer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary Material
Mohamed Loey
 
PMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration ManagementPMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration Management
Mohamed Loey
 
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption StandardComputer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Mohamed Loey
 
Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2
Mohamed Loey
 
Lecture 6: Deep Learning Applications
Lecture 6: Deep Learning ApplicationsLecture 6: Deep Learning Applications
Lecture 6: Deep Learning Applications
Mohamed Loey
 
Lecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network ModelsLecture 5: Convolutional Neural Network Models
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
Lecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning FrameworksLecture 4: Deep Learning Frameworks
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Lecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural NetworksLecture 4: How it Works: Convolutional Neural Networks
Lecture 4: How it Works: Convolutional Neural Networks
Mohamed Loey
 
Lecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural NetworksLecture 3: Convolutional Neural Networks
Lecture 3: Convolutional Neural Networks
Mohamed Loey
 
Lecture 2: Artificial Neural Network
Lecture 2: Artificial Neural NetworkLecture 2: Artificial Neural Network
Lecture 2: Artificial Neural Network
Mohamed Loey
 
Lecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer VisionLecture 1: Deep Learning for Computer Vision
Lecture 1: Deep Learning for Computer Vision
Mohamed Loey
 
Design of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer DiseasesDesign of an Intelligent System for Improving Classification of Cancer Diseases
Design of an Intelligent System for Improving Classification of Cancer Diseases
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 2
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1Computer Security - CCNA Security - Lecture 1
Computer Security - CCNA Security - Lecture 1
Mohamed Loey
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work II
Mohamed Loey
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSA
Mohamed Loey
 
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption StandardComputer Security Lecture 5: Simplified Advanced Encryption Standard
Computer Security Lecture 5: Simplified Advanced Encryption Standard
Mohamed Loey
 
Computer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary MaterialComputer Security Lecture 4.1: DES Supplementary Material
Computer Security Lecture 4.1: DES Supplementary Material
Mohamed Loey
 
PMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration ManagementPMP Lecture 4: Project Integration Management
PMP Lecture 4: Project Integration Management
Mohamed Loey
 
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption StandardComputer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Mohamed Loey
 
Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2Computer Security Lecture 3: Classical Encryption Techniques 2
Computer Security Lecture 3: Classical Encryption Techniques 2
Mohamed Loey
 
Ad

Recently uploaded (20)

Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 

Algorithms Lecture 7: Graph Algorithms

  • 1. Analysis and Design of Algorithms Graph Algorithms
  • 2. Analysis and Design of Algorithms Graph Directed vs Undirected Graph Acyclic vs Cyclic Graph Backedge Search vs Traversal Breadth First Traversal Depth First Traversal Detect Cycle in a Directed Graph
  • 3. Analysis and Design of Algorithms  Graph data structure consists of a finite set of vertices or nodes. The interconnected objects are represented by points termed as vertices, and the links that connect the vertices are called edges. A B C D E F Node or Vertices Edge
  • 4. Analysis and Design of Algorithms  Vertex: Each node of the graph is represented as a vertex.  V={A,B,C,D,E,F}  Edge: Edge represents a path between two vertices or a line between two vertices.  E={AB,AC,BD,BE,CE,DE,DF,EF} A B C D E F Node or Vertices Edge
  • 5. Analysis and Design of Algorithms A B C A B C Directed Graph Undirected Graph
  • 6. Analysis and Design of Algorithms A B C Acyclic Graph Cyclic Graph A B C
  • 7. Analysis and Design of Algorithms Backedge is an edge that is from node to itself (selfloop), or one to its ancestor. A B A
  • 8. Analysis and Design of Algorithms Search: Look for a given node Traversal: Always visit all nodes
  • 9. Analysis and Design of Algorithms Breadth First Traversal
  • 10. Analysis and Design of Algorithms Breadth First Traversal (BFT) algorithm traverses all nodes on graph in a breadthward motion and uses a queue to remember to get the next vertex.
  • 11. Analysis and Design of Algorithms Layers A B C D E F Layer1 Layer2 Layer3 Layer4
  • 12. Analysis and Design of Algorithms  Visited=  Queue=  Print: A B C D E F 0 0 0 0 0 0 A B C D E F
  • 13. Analysis and Design of Algorithms  Visited=  Queue=  Print: A B C D E F 1 0 0 0 0 0 A B C D E F
  • 14. Analysis and Design of Algorithms  Visited=  Queue= A  Print: A B C D E F 1 0 0 0 0 0 A B C D E F
  • 15. Analysis and Design of Algorithms  Visited=  Queue=  Print: A A B C D E F 1 0 0 0 0 0 A B C D E F
  • 16. Analysis and Design of Algorithms  Visited=  Queue=  Print: A A B C D E F 1 0 0 0 0 0 A B C D E F
  • 17. Analysis and Design of Algorithms  Visited=  Queue=  Print: A A B C D E F 1 0 0 0 0 0 A B C D E F
  • 18. Analysis and Design of Algorithms  Visited=  Queue=  Print: A A B C D E F 1 1 1 0 0 0 A B C D E F
  • 19. Analysis and Design of Algorithms  Visited=  Queue= B C  Print: A A B C D E F 1 1 1 0 0 0 A B C D E F
  • 20. Analysis and Design of Algorithms  Visited=  Queue= C  Print: A B A B C D E F 1 1 1 0 0 0 A B C D E F
  • 21. Analysis and Design of Algorithms  Visited=  Queue= C  Print: A B A B C D E F 1 1 1 0 0 0 A B C D E F
  • 22. Analysis and Design of Algorithms  Visited=  Queue= C  Print: A B A B C D E F 1 1 1 0 0 0 A B C D E F
  • 23. Analysis and Design of Algorithms  Visited=  Queue= C  Print: A B A B C D E F 1 1 1 1 1 0 A B C D E F
  • 24. Analysis and Design of Algorithms  Visited=  Queue= C D E  Print: A B A B C D E F 1 1 1 1 1 0 A B C D E F
  • 25. Analysis and Design of Algorithms  Visited=  Queue= D E  Print: A B C A B C D E F 1 1 1 1 1 0 A B C D E F
  • 26. Analysis and Design of Algorithms  Visited=  Queue= D E  Print: A B C A B C D E F 1 1 1 1 1 0 A B C D E F
  • 27. Analysis and Design of Algorithms  Visited=  Queue= E  Print: A B C A B C D E F 1 1 1 1 1 0 A B C D E F
  • 28. Analysis and Design of Algorithms  Visited=  Queue= E  Print: A B C D A B C D E F 1 1 1 1 1 0 A B C D E F
  • 29. Analysis and Design of Algorithms  Visited=  Queue= E  Print: A B C D A B C D E F 1 1 1 1 1 0 A B C D E F
  • 30. Analysis and Design of Algorithms  Visited=  Queue= E  Print: A B C D A B C D E F 1 1 1 1 1 1 A B C D E F
  • 31. Analysis and Design of Algorithms  Visited=  Queue= E F  Print: A B C D A B C D E F 1 1 1 1 1 1 A B C D E F
  • 32. Analysis and Design of Algorithms  Visited=  Queue= F  Print: A B C D E A B C D E F 1 1 1 1 1 1 A B C D E F
  • 33. Analysis and Design of Algorithms  Visited=  Queue= F  Print: A B C D E A B C D E F 1 1 1 1 1 1 A B C D E F
  • 34. Analysis and Design of Algorithms  Visited=  Queue= F  Print: A B C D E A B C D E F 1 1 1 1 1 1 A B C D E F
  • 35. Analysis and Design of Algorithms  Visited=  Queue=  Print: A B C D E A B C D E F 1 1 1 1 1 1 A B C D E F
  • 36. Analysis and Design of Algorithms  Visited=  Queue=  Print: A B C D E F A B C D E F 1 1 1 1 1 1 A B C D E F
  • 37. Analysis and Design of Algorithms Breadth First on Tree
  • 38. Analysis and Design of Algorithms
  • 39. Analysis and Design of Algorithms  V={0,1,2,3,4,5}  E={01,02,13,14,24,34,35,45} 0 1 2 3 4 5
  • 40. Analysis and Design of Algorithms
  • 41. Analysis and Design of Algorithms  Another Example:
  • 42. Analysis and Design of Algorithms Depth First Traversal
  • 43. Analysis and Design of Algorithms Depth First Traversal (DFT) algorithm traverses a graph in a depthward motion and uses a stack to remember to get the next vertex to start a search.
  • 44. Analysis and Design of Algorithms depthward motion A B C D E F
  • 45. Analysis and Design of Algorithms  Visited= Stack=  Print: A B C D E F 0 0 0 0 0 0 A B C D E F
  • 46. Analysis and Design of Algorithms  Visited= Stack=  Print: A B C D E F 0 0 0 0 0 0 A B C D E F
  • 47. Analysis and Design of Algorithms  Visited= Stack=  Print: A B C D E F 1 0 0 0 0 0 A B C D E F
  • 48. Analysis and Design of Algorithms  Visited= Stack=  Print: A B C D E F 1 0 0 0 0 0 A B C D E F A
  • 49. Analysis and Design of Algorithms  Visited= Stack=  Print: A A B C D E F 1 0 0 0 0 0 A B C D E F A
  • 50. Analysis and Design of Algorithms  Visited= Stack=  Print: A A B C D E F 1 0 0 0 0 0 A B C D E F A
  • 51. Analysis and Design of Algorithms  Visited= Stack=  Print: A A B C D E F 1 1 0 0 0 0 A B C D E F A
  • 52. Analysis and Design of Algorithms  Visited= Stack=  Print: A A B C D E F 1 1 0 0 0 0 A B C D E F B A
  • 53. Analysis and Design of Algorithms  Visited= Stack=  Print: A B A B C D E F 1 1 0 0 0 0 A B C D E F B A
  • 54. Analysis and Design of Algorithms  Visited= Stack=  Print: A B A B C D E F 1 1 0 0 0 0 A B C D E F B A
  • 55. Analysis and Design of Algorithms  Visited= Stack=  Print: A B A B C D E F 1 1 0 1 0 0 A B C D E F B A
  • 56. Analysis and Design of Algorithms  Visited= Stack=  Print: A B A B C D E F 1 1 0 1 0 0 A B C D E F D B A
  • 57. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D A B C D E F 1 1 0 1 0 0 A B C D E F D B A
  • 58. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D A B C D E F 1 1 0 1 0 0 A B C D E F D B A
  • 59. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D A B C D E F 1 1 0 1 0 0 A B C D E F D B A
  • 60. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D A B C D E F 1 1 0 1 1 0 A B C D E F D B A
  • 61. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D A B C D E F 1 1 0 1 1 0 A B C D E F E D B A
  • 62. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E A B C D E F 1 1 0 1 1 0 A B C D E F E D B A
  • 63. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E A B C D E F 1 1 0 1 1 0 A B C D E F E D B A
  • 64. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E A B C D E F 1 1 0 1 1 0 A B C D E F E D B A
  • 65. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E A B C D E F 1 1 0 1 1 1 A B C D E F E D B A
  • 66. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E A B C D E F 1 1 0 1 1 1 A B C D E F F E D B A
  • 67. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F A B C D E F 1 1 0 1 1 1 A B C D E F F E D B A
  • 68. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F A B C D E F 1 1 0 1 1 1 A B C D E F E D B A
  • 69. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F A B C D E F 1 1 0 1 1 1 A B C D E F E D B A
  • 70. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F A B C D E F 1 1 0 1 1 1 A B C D E F E D B A
  • 71. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F A B C D E F 1 1 1 1 1 1 A B C D E F E D B A
  • 72. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F C E D B A
  • 73. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F E D B A
  • 74. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F E D B A
  • 75. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F D B A
  • 76. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F D B A
  • 77. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F B A
  • 78. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F A
  • 79. Analysis and Design of Algorithms  Visited= Stack=  Print: A B D E F C A B C D E F 1 1 1 1 1 1 A B C D E F
  • 80. Analysis and Design of Algorithms Depth First on tree
  • 81. Analysis and Design of Algorithms
  • 82. Analysis and Design of Algorithms  V={0,1,2,3,4,5}  E={01,02,13,14,24,34,35,45} 0 1 2 3 4 5
  • 83. Analysis and Design of Algorithms
  • 84. Analysis and Design of Algorithms  Another Example:
  • 85. Analysis and Design of Algorithms Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least one cycle, else return false.
  • 86. Analysis and Design of Algorithms Depth First Traversal can be used to detect cycle in a Graph. There is a cycle in a graph only if there is a back edge present in the graph.
  • 87. Analysis and Design of Algorithms  Visited= Stack= A C B D 0 0 0 0 A B C D
  • 88. Analysis and Design of Algorithms  Visited= Stack= A C B D 0 0 0 0 A B C D
  • 89. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 0 0 0 A B C D
  • 90. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 0 0 0 A B C D A
  • 91. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 0 0 0 A B C D A
  • 92. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 0 0 A B C D A
  • 93. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 0 0 A B C D B A
  • 94. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 0 0 A B C D B A
  • 95. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 1 0 A B C D B A
  • 96. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 1 0 A B C D C B A
  • 97. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 1 0 A B C D C B A
  • 98. Analysis and Design of Algorithms  Visited= Stack= A C B D 1 1 1 0 A B C D C B A
  • 99. Analysis and Design of Algorithms Graph contains cycle A C B D
  • 100. Analysis and Design of Algorithms
  • 101. Analysis and Design of Algorithms
  • 102. Analysis and Design of Algorithms facebook.com/mloey [email protected] twitter.com/mloey linkedin.com/in/mloey [email protected] mloey.github.io
  • 103. Analysis and Design of Algorithms www.YourCompany.com © 2020 Companyname PowerPoint Business Theme. All Rights Reserved. THANKS FOR YOUR TIME