SlideShare a Scribd company logo
2
Most read
6
Most read
8
Most read
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

More Related Content

PPTX
Breadth First Search & Depth First Search
PPTX
Bfs and Dfs
PPT
Breadth first search and depth first search
PPT
Depth firstsearchalgorithm
PPT
Depth First Search ( DFS )
PPTX
Dfs presentation
PPTX
DFS and BFS
PPTX
Binary Search Tree in Data Structure
Breadth First Search & Depth First Search
Bfs and Dfs
Breadth first search and depth first search
Depth firstsearchalgorithm
Depth First Search ( DFS )
Dfs presentation
DFS and BFS
Binary Search Tree in Data Structure

What's hot (20)

PPT
Graph traversal-BFS & DFS
PPTX
Binary Tree in Data Structure
PPTX
Depth first search [dfs]
PPTX
PPT
Prim's Algorithm on minimum spanning tree
PPTX
Topological Sorting
PPTX
Presentation on Breadth First Search (BFS)
PPTX
Tower of Hanoi
PPT
Spanning trees
PPTX
Depth-First Search
PPTX
AVL Tree in Data Structure
PPTX
DFS & BFS Graph
PPTX
Insertion sort
PPTX
Depth-First Search
PPTX
A presentation on prim's and kruskal's algorithm
PPT
2.5 bfs & dfs 02
PPTX
PPTX
Uninformed search /Blind search in AI
PPTX
Tree in data structure
PPT
Breadth first search
Graph traversal-BFS & DFS
Binary Tree in Data Structure
Depth first search [dfs]
Prim's Algorithm on minimum spanning tree
Topological Sorting
Presentation on Breadth First Search (BFS)
Tower of Hanoi
Spanning trees
Depth-First Search
AVL Tree in Data Structure
DFS & BFS Graph
Insertion sort
Depth-First Search
A presentation on prim's and kruskal's algorithm
2.5 bfs & dfs 02
Uninformed search /Blind search in AI
Tree in data structure
Breadth first search
Ad

Viewers also liked (20)

PPT
Bfs and dfs in data structure
PPT
Breadth first search
PPT
Graphs bfs dfs
PPTX
PDF
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
PPTX
Graph Traversal Algorithms - Depth First Search Traversal
PDF
AI - Backtracking vs Depth-First Search (DFS)
PPT
Ch2 3-informed (heuristic) search
PPT
Depth First Search, Breadth First Search and Best First Search
PPT
Artificial intelligence
PPT
(Radhika) presentation on chapter 2 ai
PPTX
Graph in data structure
PPT
Hill climbing
PPT
Iterative deepening search
PPTX
Heap sort
PPT
17. Trees and Graphs
PPTX
Boyer more algorithm
PDF
Heuristics
PDF
알고리즘 스터디 트리
PDF
4.74 s.e. computer engineering (1)
Bfs and dfs in data structure
Breadth first search
Graphs bfs dfs
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Graph Traversal Algorithms - Depth First Search Traversal
AI - Backtracking vs Depth-First Search (DFS)
Ch2 3-informed (heuristic) search
Depth First Search, Breadth First Search and Best First Search
Artificial intelligence
(Radhika) presentation on chapter 2 ai
Graph in data structure
Hill climbing
Iterative deepening search
Heap sort
17. Trees and Graphs
Boyer more algorithm
Heuristics
알고리즘 스터디 트리
4.74 s.e. computer engineering (1)
Ad

Similar to Depth first search and breadth first searching (20)

PPTX
Breadth-First Search and Depth-First Search.pptx
PPTX
Lec 15-graph Searching in data structure and lgorithm.pptx
PPTX
Data structure
PPTX
BFS & DFS in Data Structure
PPTX
Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
PPTX
Algorithm
PPTX
Depth first Search.pptx
PDF
Bfs dfs
PPTX
Introduction of Depth First Search with example
PPTX
algoritmagraph_breadthfirstsearch_depthfirstsearch.pptx
PPTX
Breath first Search and Depth first search
PPTX
Lecture 5 - Graph Algorithms BFS and DFS.pptx
PDF
ada-191015145338.pdf
PPTX
Breadth First Search (BFS)
PPTX
kumattt).pptx
PPTX
breadth first search
PPTX
DFS & BFS in Computer Algorithm
PPTX
Problem Solving through Search - Uninformed Search
PPTX
dfs.pptx
PDF
U1 L5 DAA.pdf
Breadth-First Search and Depth-First Search.pptx
Lec 15-graph Searching in data structure and lgorithm.pptx
Data structure
BFS & DFS in Data Structure
Riya Bepari_34700122020_Artificial Intelligence_PEC-IT501B.pptx
Algorithm
Depth first Search.pptx
Bfs dfs
Introduction of Depth First Search with example
algoritmagraph_breadthfirstsearch_depthfirstsearch.pptx
Breath first Search and Depth first search
Lecture 5 - Graph Algorithms BFS and DFS.pptx
ada-191015145338.pdf
Breadth First Search (BFS)
kumattt).pptx
breadth first search
DFS & BFS in Computer Algorithm
Problem Solving through Search - Uninformed Search
dfs.pptx
U1 L5 DAA.pdf

More from Kawsar Hamid Sumon (7)

PPTX
HOW TO READ PLM (TACK PACK) FOR PVH.pptx
PPTX
How to read Tech pack (PLM) any customer
PPTX
Simulation, Modeling, it’s application, advantage & disadvantage
PPTX
Java packages oop
PPTX
Memory system of a compture
PPTX
Temperature and laws of thermodynamics
PPTX
Number system conversion
HOW TO READ PLM (TACK PACK) FOR PVH.pptx
How to read Tech pack (PLM) any customer
Simulation, Modeling, it’s application, advantage & disadvantage
Java packages oop
Memory system of a compture
Temperature and laws of thermodynamics
Number system conversion

Recently uploaded (20)

PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Welding lecture in detail for understanding
PPTX
Sustainable Sites - Green Building Construction
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
additive manufacturing of ss316l using mig welding
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
DOCX
573137875-Attendance-Management-System-original
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Model Code of Practice - Construction Work - 21102022 .pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
OOP with Java - Java Introduction (Basics)
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Welding lecture in detail for understanding
Sustainable Sites - Green Building Construction
UNIT 4 Total Quality Management .pptx
additive manufacturing of ss316l using mig welding
R24 SURVEYING LAB MANUAL for civil enggi
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
573137875-Attendance-Management-System-original
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx

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