4
Most read
6
Most read
8
Most read
BFS (Breadth First Search)
BFS traversal of a graph produces a spanning
tree as final result. Spanning Tree is a graph
without loops. We use Queue data
structure with maximum size of total number of
vertices in the graph to implement BFS
traversal.
Step 1 - Define a Queue of size total number of vertices
in the graph.
Step 2 - Select any vertex as starting point for traversal.
Visit that vertex and insert it into the Queue.
Step 3 - Visit all the non-visited adjacent vertices of the
vertex which is at front of the Queue and insert them into
the Queue.
Step 4 - When there is no new vertex to be visited from
the vertex which is at front of the Queue then delete that
vertex.
Step 5 - Repeat steps 3 and 4 until queue becomes empty.
Step 6 -When queue becomes empty, then produce final
spanning tree by removing unused edges from the graph
Traversal Steps
Bfs new
Bfs new
Bfs new
Bfs new
Bfs new
Bfs new
Bfs new
Bfs new
Bfs new
Bfs new
Thank You

More Related Content

PPTX
DFS_New.pptx
PPTX
Stacks IN DATA STRUCTURES
PPTX
Stack_Data_Structure.pptx
PPTX
AVL Tree Data Structure
PPTX
Double Linked List (Algorithm)
PPTX
Tree_Definition.pptx
PPT
Linked lists
PPTX
Doubly Linked List
DFS_New.pptx
Stacks IN DATA STRUCTURES
Stack_Data_Structure.pptx
AVL Tree Data Structure
Double Linked List (Algorithm)
Tree_Definition.pptx
Linked lists
Doubly Linked List

What's hot (20)

PPTX
Priority Queue in Data Structure
PPTX
DFS and BFS
PPTX
Link_List.pptx
PPT
Doubly linked list
PPT
Spanning trees
PPTX
Graph traversals in Data Structures
PDF
Expression trees
PPT
Linked list
PDF
Red black tree
PPTX
Queue_Data_Structure.pptx
PPTX
PPT
BINARY TREE REPRESENTATION.ppt
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
PPT
Data Structure and Algorithms Linked List
PPTX
Linked list
PPT
Graph traversal-BFS & DFS
PPTX
Data structure by Digvijay
PPTX
The Stack And Recursion
PPT
Queue data structure
PDF
Binary search tree operations
Priority Queue in Data Structure
DFS and BFS
Link_List.pptx
Doubly linked list
Spanning trees
Graph traversals in Data Structures
Expression trees
Linked list
Red black tree
Queue_Data_Structure.pptx
BINARY TREE REPRESENTATION.ppt
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structure and Algorithms Linked List
Linked list
Graph traversal-BFS & DFS
Data structure by Digvijay
The Stack And Recursion
Queue data structure
Binary search tree operations
Ad

Similar to Bfs new (20)

PPTX
Breadth First Search or BFS for a Graph traversal
PPTX
bfs tree searching ,sortingUntitled presentation.pptx
PPTX
breadth first traversal- tree traversal
PPTX
BFS & DFS in Data Structure
PDF
graphtraversals.pdf
PPTX
Bfs present
PPTX
Presentation on Breadth First Search (BFS)
PPTX
Breadth-First-Search algorithm with Code
PPTX
Breadth first search (Bfs)
PPTX
BFS (Breadth First Search) Tree Traversal
DOC
BFS, Breadth first search | Search Traversal Algorithm
PPTX
Breadth first search (bfs)
PPT
14_Graph Traversalllllllllllllllllll.ppt
PPTX
Breadth-First Search and Depth-First Search.pptx
PPTX
BFS and DFS
PPTX
Lecture 16 graphs traversal
PDF
Breadth First Search .
PPTX
Breath first Search and Depth first search
PPTX
Breadth First Search with example and solutions
PPTX
bfs and dfs (data structures).pptx
Breadth First Search or BFS for a Graph traversal
bfs tree searching ,sortingUntitled presentation.pptx
breadth first traversal- tree traversal
BFS & DFS in Data Structure
graphtraversals.pdf
Bfs present
Presentation on Breadth First Search (BFS)
Breadth-First-Search algorithm with Code
Breadth first search (Bfs)
BFS (Breadth First Search) Tree Traversal
BFS, Breadth first search | Search Traversal Algorithm
Breadth first search (bfs)
14_Graph Traversalllllllllllllllllll.ppt
Breadth-First Search and Depth-First Search.pptx
BFS and DFS
Lecture 16 graphs traversal
Breadth First Search .
Breath first Search and Depth first search
Breadth First Search with example and solutions
bfs and dfs (data structures).pptx
Ad

More from sandeep54552 (20)

PPTX
Dijkstra Searching Algorithms Shortest.pptx
PPTX
E_R-Diagram (2).pptx
PPTX
Dijkstra Searching Algorithms.pptx
PPT
Agents_AI.ppt
PPT
YCMOU_FYBCA_DS_Unit-7.ppt
PPTX
Stack_Application_Infix_Prefix.pptx
PPTX
Heap_Sort1.pptx
PPTX
Quick_sort1.pptx
PPTX
Templates in c++
PPTX
File handling in c++
PPTX
Exception handling in c++
PPTX
Inheritance in c++
PPTX
Constructor and Destructors in C++
PPTX
C++ programming introduction
PPTX
Jsp tag library
PDF
Hill climbing algorithm in artificial intelligence
PPTX
Session bean
PPTX
Greedy algorithms
PPTX
A star algorithms
PPTX
Bfs new
Dijkstra Searching Algorithms Shortest.pptx
E_R-Diagram (2).pptx
Dijkstra Searching Algorithms.pptx
Agents_AI.ppt
YCMOU_FYBCA_DS_Unit-7.ppt
Stack_Application_Infix_Prefix.pptx
Heap_Sort1.pptx
Quick_sort1.pptx
Templates in c++
File handling in c++
Exception handling in c++
Inheritance in c++
Constructor and Destructors in C++
C++ programming introduction
Jsp tag library
Hill climbing algorithm in artificial intelligence
Session bean
Greedy algorithms
A star algorithms
Bfs new

Recently uploaded (20)

PPTX
CyberSecurity Mobile and Wireless Devices
PPTX
wireless networks, mobile computing.pptx
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PDF
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
Unit1 - AIML Chapter 1 concept and ethics
PDF
Computer organization and architecuture Digital Notes....pdf
PDF
First part_B-Image Processing - 1 of 2).pdf
PPTX
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
PDF
Design of Material Handling Equipment Lecture Note
PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
Principal presentation for NAAC (1).pptx
PDF
Cryptography and Network Security-Module-I.pdf
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPTX
Measurement Uncertainty and Measurement System analysis
PPTX
Information Storage and Retrieval Techniques Unit III
CyberSecurity Mobile and Wireless Devices
wireless networks, mobile computing.pptx
MLpara ingenieira CIVIL, meca Y AMBIENTAL
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Unit1 - AIML Chapter 1 concept and ethics
Computer organization and architecuture Digital Notes....pdf
First part_B-Image Processing - 1 of 2).pdf
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
Design of Material Handling Equipment Lecture Note
Module 8- Technological and Communication Skills.pptx
Principal presentation for NAAC (1).pptx
Cryptography and Network Security-Module-I.pdf
August -2025_Top10 Read_Articles_ijait.pdf
"Array and Linked List in Data Structures with Types, Operations, Implementat...
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
Measurement Uncertainty and Measurement System analysis
Information Storage and Retrieval Techniques Unit III

Bfs new

  • 2. BFS traversal of a graph produces a spanning tree as final result. Spanning Tree is a graph without loops. We use Queue data structure with maximum size of total number of vertices in the graph to implement BFS traversal.
  • 3. Step 1 - Define a Queue of size total number of vertices in the graph. Step 2 - Select any vertex as starting point for traversal. Visit that vertex and insert it into the Queue. Step 3 - Visit all the non-visited adjacent vertices of the vertex which is at front of the Queue and insert them into the Queue. Step 4 - When there is no new vertex to be visited from the vertex which is at front of the Queue then delete that vertex. Step 5 - Repeat steps 3 and 4 until queue becomes empty. Step 6 -When queue becomes empty, then produce final spanning tree by removing unused edges from the graph Traversal Steps