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
 
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
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 
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
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 

Similar to Algorithms Lecture 7: Graph Algorithms (20)

Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdf
HarshNagda5
 
l01-intro (3).ppt
l01-intro (3).pptl01-intro (3).ppt
l01-intro (3).ppt
ssuser15a62a
 
CS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptxCS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptx
BolliniNivas
 
Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
ALIZAIB KHAN
 
Algorithms : Introduction and Analysis
Algorithms : Introduction and AnalysisAlgorithms : Introduction and Analysis
Algorithms : Introduction and Analysis
Dhrumil Patel
 
Lec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdfLec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdf
MAJDABDALLAH3
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
Syed Zaid Irshad
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUERUNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its workingUNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
SauravPawar14
 
Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
NetraBansal3
 
L01 intro-daa - ppt1
L01 intro-daa - ppt1L01 intro-daa - ppt1
L01 intro-daa - ppt1
sankaran L
 
Data Structure - Lecture 1 - Introduction.pdf
Data Structure  - Lecture 1 - Introduction.pdfData Structure  - Lecture 1 - Introduction.pdf
Data Structure - Lecture 1 - Introduction.pdf
donotreply20
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
Vinay Kumar C
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentationChp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdf
HarshNagda5
 
CS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptxCS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptx
BolliniNivas
 
Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
ALIZAIB KHAN
 
Algorithms : Introduction and Analysis
Algorithms : Introduction and AnalysisAlgorithms : Introduction and Analysis
Algorithms : Introduction and Analysis
Dhrumil Patel
 
Lec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdfLec01-Algorithems - Introduction and Overview.pdf
Lec01-Algorithems - Introduction and Overview.pdf
MAJDABDALLAH3
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
Syed Zaid Irshad
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUERUNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its workingUNIT 1- Design Analysis of algorithms and its working
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
1. Introduction to Algorithms, Specification of Algorithm, Complexity.pdf
NetraBansal3
 
L01 intro-daa - ppt1
L01 intro-daa - ppt1L01 intro-daa - ppt1
L01 intro-daa - ppt1
sankaran L
 
Data Structure - Lecture 1 - Introduction.pdf
Data Structure  - Lecture 1 - Introduction.pdfData Structure  - Lecture 1 - Introduction.pdf
Data Structure - Lecture 1 - Introduction.pdf
donotreply20
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentationChp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
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
 
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
 
Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1
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
 
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
 
Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1Computer Security Lecture 2: Classical Encryption Techniques 1
Computer Security Lecture 2: Classical Encryption Techniques 1
Mohamed Loey
 
Ad

Recently uploaded (20)

What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
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
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
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
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
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
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
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
 
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
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
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.
 
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
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
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
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
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
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
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
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
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
 
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
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
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
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 

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