Breadth
First Search
PREPARED BY: SUPRIYO DANA
UNIVERSITY ROLL NO : 34200123067
PAPER NAME : ARTIFICIAL INTELLIGENCE; PAPER CODE: PECIT501B
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
FUTURE INSTITUTE OF TECHNOLOGY
2.
CONTENT
Introduction to BFS
KeyCharacteristics
Use Cases
How BFS Works
Example
Advantages and Disadvantages
Conclusion and Applications
34200123067SUPRIYODANA
3.
o Breadth-First Search(BFS) is a graph
traversal algorithm that explores vertices
level by level. It begins at a starting node
and explores all its neighboring nodes at
the present depth prior to moving on to
nodes at the next depth level.
Introduction to BFS
34200123067SUPRIYODANA
4.
Key Characteristics &Use Cases
Key Characteristics:
• BFS uses a queue data structure.
• It explores nodes in layers, i.e., all nodes at the present depth are visited
before any nodes at the next depth level.
Use Cases :
• Finding the shortest path in unweighted graphs.
• Crawling the web.
• Peer-to-peer networks.
• Network broadcast.
34200123067SUPRIYODANA
5.
How BFS Works
34200123067SUPRIYODANA
Step-by-StepProcess:
• Initialization: Start from the root node, mark it as visited, and enqueue it.
• Dequeue & Explore: Dequeue a node from the front of the queue, and explore
its unvisited neighbors.
• Enqueue Neighbors: Mark each unvisited neighbor as visited and enqueue
them.
• Repeat: Repeat the process until the queue is empty.
Queue Data Structure:
• A queue is essential to manage the nodes to be explored, following the First-In-
First-Out (FIFO) principle.
Level-wise Exploration:
• BFS ensures that nodes are explored in the order of their distance from the
root, level by level.
Advantages and Disadvantages
oShortestPath: Guarantees finding the shortest
path in unweighted graphs.
oSimple: Easy to implement and understand.
Advantages
oMemory-Intensive: Can be memory-intensive for
large graphs or wide trees.
oNot Suitable for Weighted Graphs: BFS does not
handle weighted edges well; Dijkstra's algorithm or
A* is preferred in those cases.
Disadvantages
34200123067SUPRIYODANA
10.
Conclusion and Applications
BFSis a foundational graph traversal technique that explores nodes level by level. It is
effective for unweighted graphs and certain tree-based problems.
BFS is widely used in AI, networking, and other fields where graph-based problem-
solving is required. Examples include finding shortest paths, solving puzzles, and
searching in peer-to-peer networks.
BFS is a versatile algorithm that, despite its simplicity, has profound applications
across many domains.
34200123067SUPRIYODANA