SlideShare uma empresa Scribd logo
1 de 8
CSE-134
Submitted by Mohammad Kawsar Hamid Submitted to Kawser Wajed Nafi
ID:131-15-2223 Daffodil International University
1.Depth first search was first investigated by French
Mathematician Charles Pierre tremaux.
2.It is an algorithm for traversing tree or graph data
structures.
3.One starts at the root and explores as deep as
possible along each branch before backtracking.
4.It can be implemented using stack.

Depth-first searching
 A depth-first search (DFS)
explores a path all the way
to a leaf before backtracking
and exploring another path.
 For example, after
searching A, then B, then D,
the search backtracks and
tries another path from B.
 Node are explored in the
order A B D E H L M N I
O P C F G J K Q.
 N will be found before J.L M N O P
G
Q
H JI K
FED
B C
A

1.In Depth first search edges are explored out of the most recently dis-covered
vertex. Only edges to unexplored vertices are explored.
2.When all of vertices edges have been explored, the search “back-tracks” to
explore edges leaving the vertex from which vertex was discovered.
3.The process continues until we have discovered all the vertices that are
reachable from the original source vertex.
4.If any undiscovered vertices remain, then one of them is selected as a new
source vertex.
5.This process if repeated until all vertices are discovered.
Idea of The Depth First Search
Algorithm
1.The Breadth first search begins at a root node and inspects all
the neighboring nodes.
2.Then for each of those neighbor nodes in turn, it inspects their
neighbor nodes which were unvisited, and so on.
3.It can be implemented using queue.

Breadth First Searching
 A breadth-first search (BFS)
explores nodes nearest the
root before exploring nodes
further away.
 For example, after
searching A, then B, then C,
the search proceeds with D,
E, F, G.
 Node are explored in the
order A B C D E F G H I J K L
M N O P Q.
 J will be found before N.
L M N O P
G
Q
H JI K
FED
B C
A

 Enqueue the root node
 Dequeue a node and examine it
 If the element sought is found in this node, quit the search and return a result.
 Otherwise enqueue any successors (the direct child nodes) that have not yet been
discovered.
 If the queue is empty, every node on the graph has been examined – quit the
search and return "not found".
 If the queue is not empty, repeat from Step 2.
Idea of Breadth First Search
Depth first search and breadth first searching

Mais conteúdo relacionado

Mais procurados

Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 

Mais procurados (20)

Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 
Dfs
DfsDfs
Dfs
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
Iterative deepening search
Iterative deepening searchIterative deepening search
Iterative deepening search
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
 
BFS
BFSBFS
BFS
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
Linked list
Linked listLinked list
Linked list
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Trees and graphs
Trees and graphsTrees and graphs
Trees and graphs
 
Lecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmLecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithm
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Depth firstsearchalgorithm
Depth firstsearchalgorithmDepth firstsearchalgorithm
Depth firstsearchalgorithm
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)
 
Graph traversal-BFS & DFS
Graph traversal-BFS & DFSGraph traversal-BFS & DFS
Graph traversal-BFS & DFS
 

Destaque

Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
Alizay Khan
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
chandsek666
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai
Radhika Srinivasan
 
4.74 s.e. computer engineering (1)
4.74 s.e. computer engineering (1)4.74 s.e. computer engineering (1)
4.74 s.e. computer engineering (1)
Aditya66086
 

Destaque (20)

Breadth first search
Breadth first searchBreadth first search
Breadth first search
 
Graphs bfs dfs
Graphs bfs dfsGraphs bfs dfs
Graphs bfs dfs
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
 
Graph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search TraversalGraph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search Traversal
 
AI - Backtracking vs Depth-First Search (DFS)
AI - Backtracking vs Depth-First Search (DFS)AI - Backtracking vs Depth-First Search (DFS)
AI - Backtracking vs Depth-First Search (DFS)
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
 
Depth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First SearchDepth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First Search
 
DFS & BFS Graph
DFS & BFS GraphDFS & BFS Graph
DFS & BFS Graph
 
2.5 bfs & dfs 02
2.5 bfs & dfs 022.5 bfs & dfs 02
2.5 bfs & dfs 02
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Heap sort
Heap sortHeap sort
Heap sort
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
 
Boyer more algorithm
Boyer more algorithmBoyer more algorithm
Boyer more algorithm
 
Heuristics
HeuristicsHeuristics
Heuristics
 
알고리즘 스터디 트리
알고리즘 스터디   트리알고리즘 스터디   트리
알고리즘 스터디 트리
 
4.74 s.e. computer engineering (1)
4.74 s.e. computer engineering (1)4.74 s.e. computer engineering (1)
4.74 s.e. computer engineering (1)
 

Semelhante a Depth first search and breadth first searching

Semelhante a Depth first search and breadth first searching (14)

Depth first Search.pptx
Depth first Search.pptxDepth first Search.pptx
Depth first Search.pptx
 
Uniformed tree searching
Uniformed tree searching Uniformed tree searching
Uniformed tree searching
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
Analysis and design of algorithms part 3
Analysis and design of algorithms part 3Analysis and design of algorithms part 3
Analysis and design of algorithms part 3
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
Algorithm presentation (1)
Algorithm presentation (1)Algorithm presentation (1)
Algorithm presentation (1)
 
Data structure
Data structureData structure
Data structure
 
searching technique
searching techniquesearching technique
searching technique
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
 
kumattt).pptx
kumattt).pptxkumattt).pptx
kumattt).pptx
 
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptxRPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
 
Bfs and dfs
Bfs and dfsBfs and dfs
Bfs and dfs
 

Último

Último (20)

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 

Depth first search and breadth first searching

  • 1. CSE-134 Submitted by Mohammad Kawsar Hamid Submitted to Kawser Wajed Nafi ID:131-15-2223 Daffodil International University
  • 2. 1.Depth first search was first investigated by French Mathematician Charles Pierre tremaux. 2.It is an algorithm for traversing tree or graph data structures. 3.One starts at the root and explores as deep as possible along each branch before backtracking. 4.It can be implemented using stack.
  • 3.  Depth-first searching  A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path.  For example, after searching A, then B, then D, the search backtracks and tries another path from B.  Node are explored in the order A B D E H L M N I O P C F G J K Q.  N will be found before J.L M N O P G Q H JI K FED B C A
  • 4.  1.In Depth first search edges are explored out of the most recently dis-covered vertex. Only edges to unexplored vertices are explored. 2.When all of vertices edges have been explored, the search “back-tracks” to explore edges leaving the vertex from which vertex was discovered. 3.The process continues until we have discovered all the vertices that are reachable from the original source vertex. 4.If any undiscovered vertices remain, then one of them is selected as a new source vertex. 5.This process if repeated until all vertices are discovered. Idea of The Depth First Search Algorithm
  • 5. 1.The Breadth first search begins at a root node and inspects all the neighboring nodes. 2.Then for each of those neighbor nodes in turn, it inspects their neighbor nodes which were unvisited, and so on. 3.It can be implemented using queue.
  • 6.  Breadth First Searching  A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away.  For example, after searching A, then B, then C, the search proceeds with D, E, F, G.  Node are explored in the order A B C D E F G H I J K L M N O P Q.  J will be found before N. L M N O P G Q H JI K FED B C A
  • 7.   Enqueue the root node  Dequeue a node and examine it  If the element sought is found in this node, quit the search and return a result.  Otherwise enqueue any successors (the direct child nodes) that have not yet been discovered.  If the queue is empty, every node on the graph has been examined – quit the search and return "not found".  If the queue is not empty, repeat from Step 2. Idea of Breadth First Search