SlideShare a Scribd company logo
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

What's hot

Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
sandeep54552
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
Alizay Khan
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
Masud Parvaze
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
Apurbo Datta
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
Kapil Dahal
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
Krish_ver2
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Data structure tries
Data structure triesData structure tries
Data structure tries
Md. Naim khan
 
Heap sort
Heap sortHeap sort
Heap sort
Mohd Arif
 
Bubble sort
Bubble sortBubble sort
Bubble sort
Manek Ar
 
Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
Syed Zaid Irshad
 
Hashing in datastructure
Hashing in datastructureHashing in datastructure
Hashing in datastructure
rajshreemuthiah
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
Sagacious IT Solution
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
Kirti Verma
 
8 queen problem
8 queen problem8 queen problem
8 queen problem
NagajothiN1
 

What's hot (20)

Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
stack & queue
stack & queuestack & queue
stack & queue
 
Data structure tries
Data structure triesData structure tries
Data structure tries
 
Heap sort
Heap sortHeap sort
Heap sort
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
 
Hashing in datastructure
Hashing in datastructureHashing in datastructure
Hashing in datastructure
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
8 queen problem
8 queen problem8 queen problem
8 queen problem
 

Viewers also liked

Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
Ankit Kumar Singh
 
Breadth first search
Breadth first searchBreadth first search
Breadth first search
Vignesh Prasanna
 
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 ...
Fernando Rodrigues Junior
 
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
Amrinder Arora
 
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)
Johnnatan Messias
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
chandsek666
 
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
Adri Jovin
 
DFS & BFS Graph
DFS & BFS GraphDFS & BFS Graph
DFS & BFS Graph
Mahfuzul Yamin
 
2.5 bfs & dfs 02
2.5 bfs & dfs 022.5 bfs & dfs 02
2.5 bfs & dfs 02
Krish_ver2
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
Umesh Meher
 
(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
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Hill climbing
Hill climbingHill climbing
Hill climbing
Mohammad Faizan
 
Iterative deepening search
Iterative deepening searchIterative deepening search
Iterative deepening search
Ashis Kumar Chanda
 
Heap sort
Heap sortHeap sort
Heap sort
Ayesha Tahir
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
Intro C# Book
 
Boyer more algorithm
Boyer more algorithmBoyer more algorithm
Boyer more algorithm
Kritika Purohit
 
알고리즘 스터디 트리
알고리즘 스터디   트리알고리즘 스터디   트리
알고리즘 스터디 트리
seungdols
 
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
 

Viewers also liked (20)

Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
 
Breadth first search
Breadth first searchBreadth first search
Breadth 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 ...
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
 
Iterative deepening search
Iterative deepening searchIterative deepening search
Iterative deepening search
 
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)
 

Similar to Depth first search and breadth first searching

Depth first Search.pptx
Depth first Search.pptxDepth first Search.pptx
Depth first Search.pptx
AleezaShakeel3
 
Uniformed tree searching
Uniformed tree searching Uniformed tree searching
Uniformed tree searching
Ayaelshiwi
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
Nazir Ahmed
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
Andrew Ferlitsch
 
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
Deepak John
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
Subash Chandra Pakhrin
 
Algorithm presentation (1)
Algorithm presentation (1)Algorithm presentation (1)
Algorithm presentation (1)
NushratRia
 
Data structure
Data structureData structure
Data structure
lalithambiga kamaraj
 
searching technique
searching techniquesearching technique
searching technique
colleges
 
kumattt).pptx
kumattt).pptxkumattt).pptx
kumattt).pptx
gurukhade1
 
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
RahulkumarTivarekar1
 
Bfs and dfs
Bfs and dfsBfs and dfs
Bfs and dfs
utsav patel
 

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

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
 
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
 
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
 

Recently uploaded

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
Madhumitha Jayaram
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 

Recently uploaded (20)

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 

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