SlideShare a Scribd company logo
4
Most read
5
Most read
9
Most read
WELCOME
Name: Dhrumil I. Panchal
Enrollment No.: 170410107053
Subject: Analysis and Design of Algorithms
Branch: Computer Engineering (B.E.)
Year: 2019-20
TOPIC
Breadth-First Search
CONTAIN
Introduction
Algorithm
Example
BFS
 Given a graph G = (V, E) and a distinguished source vertex s, breadth-
first search systematically explores the edges of G to "discover" every
vertex that is reachable from s.
 It computes the distance (smallest number of edges) from s to each
reachable vertex.
 It also produces a "breadth-first tree" with root s that contains all
reachable vertices.
 For any vertex v reachable from s, the path in the breadth-first tree
from s to v corresponds to a "shortest path" from s to v in G, that is, a
path containing the smallest number of edges.
CONTI…
The algorithm works on both directed and undirected graphs.
Breadth-first search is so named because it expands the frontier
between discovered and undiscovered vertices uniformly across
the breadth of the frontier.
That is, the algorithm discovers all vertices at distance k from s
before discovering any vertices at distance k + 1.
BFS (G, S)
for each vertex u ϵ G.V – {s}
u.color = WHITE
u.d = ∞
u.π = NIL
s.color = GRAY
s.d = 0
s. π = NIL
Q = Ø
ENQUEUE (Q, s)
BFS (G, S)
while Q != Ø
u = DEQUEUE (Q)
for each v ϵ G.adj[u]
if v.color == WHITE
v.color = GRAY
v.d = u.d + 1
v. π = u
ENQUEUE (Q, v)
u.color = BLACK
CONTI…
Breadth first search in not naturally recursive. To understand the
differences and similarities, let us first consider the non-recursive
formulation of DFS algorithm.
Let stack be a data type allowing two operations PUSH and POP.
It handles elements in LIFO odder.
The function top denotes the first element at the top of the stack.
EXAMPLE
IF NODE 1 IS STARTING POINT
REFERENCES
Inspiration from Prof. Jayna B. Shah
Notes of ADA
Textbook of ADA
Images from Google Images
Some my own Knowledge
THANK YOU

More Related Content

PDF
Breadth First Search Algorithm In 10 Minutes | Artificial Intelligence Tutori...
PPTX
PPTX
Breadth first search (Bfs)
PPTX
Presentation on Breadth First Search (BFS)
PDF
Breadth first search signed
PPTX
DFS and BFS
PPT
Prim's Algorithm on minimum spanning tree
PPTX
Bfs and Dfs
Breadth First Search Algorithm In 10 Minutes | Artificial Intelligence Tutori...
Breadth first search (Bfs)
Presentation on Breadth First Search (BFS)
Breadth first search signed
DFS and BFS
Prim's Algorithm on minimum spanning tree
Bfs and Dfs

What's hot (20)

PPT
Breadth first search
PPTX
Kruskal Algorithm
PPTX
Deque and its applications
PPTX
Depth first search [dfs]
PPTX
Astar algorithm
PPT
Breadth first search and depth first search
PDF
Shortest Path in Graph
PPTX
Dfs presentation
PPTX
DAA-Floyd Warshall Algorithm.pptx
PPTX
Doubly Linked List
PPTX
unit 4 for trees data structure notes it is
PPTX
Tower of Hanoi
PPTX
1.2. introduction to automata theory
PPTX
PPTX
Shortest path algorithm
PPTX
Searching
PPT
Sets and disjoint sets union123
PPTX
Breadth First Search & Depth First Search
PPTX
Queue in Data Structure
PPTX
daa-unit-3-greedy method
Breadth first search
Kruskal Algorithm
Deque and its applications
Depth first search [dfs]
Astar algorithm
Breadth first search and depth first search
Shortest Path in Graph
Dfs presentation
DAA-Floyd Warshall Algorithm.pptx
Doubly Linked List
unit 4 for trees data structure notes it is
Tower of Hanoi
1.2. introduction to automata theory
Shortest path algorithm
Searching
Sets and disjoint sets union123
Breadth First Search & Depth First Search
Queue in Data Structure
daa-unit-3-greedy method
Ad

Similar to Breadth First Search (BFS) (20)

DOC
BFS, Breadth first search | Search Traversal Algorithm
PDF
Bfs dfs
PPTX
Technical_Seminar .pptx
PPTX
Lecture 5 - Graph Algorithms BFS and DFS.pptx
PPTX
Algorithm
PPTX
Breadth-First Search and Depth-First Search.pptx
PPTX
Algorithm Design and Complexity - Course 7
PPTX
Data structure
PPTX
Breath first Search and Depth first search
PPTX
kumattt).pptx
PPT
Graph 02
PPT
Chapter 23 aoa
PPTX
Lec 15-graph Searching in data structure and lgorithm.pptx
PPTX
Graph Traversal Algorithm
PPTX
algoritmagraph_breadthfirstsearch_depthfirstsearch.pptx
PDF
Analysis and design of algorithms part 3
PPTX
Sec B Graph traversal.pptx
PPTX
Unit ii-ppt
PPT
Graph traversal-BFS & DFS
PPT
B.tech admission in india
BFS, Breadth first search | Search Traversal Algorithm
Bfs dfs
Technical_Seminar .pptx
Lecture 5 - Graph Algorithms BFS and DFS.pptx
Algorithm
Breadth-First Search and Depth-First Search.pptx
Algorithm Design and Complexity - Course 7
Data structure
Breath first Search and Depth first search
kumattt).pptx
Graph 02
Chapter 23 aoa
Lec 15-graph Searching in data structure and lgorithm.pptx
Graph Traversal Algorithm
algoritmagraph_breadthfirstsearch_depthfirstsearch.pptx
Analysis and design of algorithms part 3
Sec B Graph traversal.pptx
Unit ii-ppt
Graph traversal-BFS & DFS
B.tech admission in india
Ad

More from Dhrumil Panchal (20)

PPTX
YouTube Cryptocurrency Scam
PPTX
This and Static Keyword
PPTX
Servlet and Servlet Life Cycle
PPTX
Properties and Indexers
PPTX
Chomsky Normal Form
PPTX
IEEE 802.11 Architecture and Services
PPTX
Key roles for successful analytic project in Data Mining
PPTX
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
PPTX
Different Software Testing Types and CMM Standard
PPTX
Web Design Issues
PPTX
Toy Interpreter
PPTX
Traditional Problems Associated with Computer Crime
PPTX
Timing Diagram of MVI Instruction of 8085 Microprocessor
PPTX
File Management – File Concept, access methods, File types and File Operation
PPTX
Constructor and Types of Constructors
PPTX
Types of Instruction Format
PPTX
Types of Cables(Guided Media for Transmisson)
PPTX
Global Service for Mobile Communication
PPTX
Denial of Service Attack
PPTX
Fourier Series
YouTube Cryptocurrency Scam
This and Static Keyword
Servlet and Servlet Life Cycle
Properties and Indexers
Chomsky Normal Form
IEEE 802.11 Architecture and Services
Key roles for successful analytic project in Data Mining
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Different Software Testing Types and CMM Standard
Web Design Issues
Toy Interpreter
Traditional Problems Associated with Computer Crime
Timing Diagram of MVI Instruction of 8085 Microprocessor
File Management – File Concept, access methods, File types and File Operation
Constructor and Types of Constructors
Types of Instruction Format
Types of Cables(Guided Media for Transmisson)
Global Service for Mobile Communication
Denial of Service Attack
Fourier Series

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPT
Project quality management in manufacturing
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
Sustainable Sites - Green Building Construction
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Welding lecture in detail for understanding
DOCX
573137875-Attendance-Management-System-original
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Project quality management in manufacturing
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Construction Project Organization Group 2.pptx
Foundation to blockchain - A guide to Blockchain Tech
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Structs to JSON How Go Powers REST APIs.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Geodesy 1.pptx...............................................
Sustainable Sites - Green Building Construction
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mechanical Engineering MATERIALS Selection
Welding lecture in detail for understanding
573137875-Attendance-Management-System-original
Embodied AI: Ushering in the Next Era of Intelligent Systems

Breadth First Search (BFS)

  • 1. WELCOME Name: Dhrumil I. Panchal Enrollment No.: 170410107053 Subject: Analysis and Design of Algorithms Branch: Computer Engineering (B.E.) Year: 2019-20
  • 4. BFS  Given a graph G = (V, E) and a distinguished source vertex s, breadth- first search systematically explores the edges of G to "discover" every vertex that is reachable from s.  It computes the distance (smallest number of edges) from s to each reachable vertex.  It also produces a "breadth-first tree" with root s that contains all reachable vertices.  For any vertex v reachable from s, the path in the breadth-first tree from s to v corresponds to a "shortest path" from s to v in G, that is, a path containing the smallest number of edges.
  • 5. CONTI… The algorithm works on both directed and undirected graphs. Breadth-first search is so named because it expands the frontier between discovered and undiscovered vertices uniformly across the breadth of the frontier. That is, the algorithm discovers all vertices at distance k from s before discovering any vertices at distance k + 1.
  • 6. BFS (G, S) for each vertex u ϵ G.V – {s} u.color = WHITE u.d = ∞ u.π = NIL s.color = GRAY s.d = 0 s. π = NIL Q = Ø ENQUEUE (Q, s)
  • 7. BFS (G, S) while Q != Ø u = DEQUEUE (Q) for each v ϵ G.adj[u] if v.color == WHITE v.color = GRAY v.d = u.d + 1 v. π = u ENQUEUE (Q, v) u.color = BLACK
  • 8. CONTI… Breadth first search in not naturally recursive. To understand the differences and similarities, let us first consider the non-recursive formulation of DFS algorithm. Let stack be a data type allowing two operations PUSH and POP. It handles elements in LIFO odder. The function top denotes the first element at the top of the stack.
  • 10. IF NODE 1 IS STARTING POINT
  • 11. REFERENCES Inspiration from Prof. Jayna B. Shah Notes of ADA Textbook of ADA Images from Google Images Some my own Knowledge