0% found this document useful (0 votes)
45 views2 pages

DAA Practical-10-1

Breadth First Search (BFS) is an algorithm for traversing graphs. It visits neighbor nodes before child nodes, using a queue. The algorithm starts at a source node and explores the entire current level before moving to the next. It ensures each node is visited once. The time complexity is O(V+E) and space complexity is O(V), where V is nodes and E is edges. The student implemented and analyzed BFS, concluding they successfully analyzed its time complexity.

Uploaded by

Mr Unknown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

DAA Practical-10-1

Breadth First Search (BFS) is an algorithm for traversing graphs. It visits neighbor nodes before child nodes, using a queue. The algorithm starts at a source node and explores the entire current level before moving to the next. It ensures each node is visited once. The time complexity is O(V+E) and space complexity is O(V), where V is nodes and E is edges. The student implemented and analyzed BFS, concluding they successfully analyzed its time complexity.

Uploaded by

Mr Unknown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name Priyesh Gawali

Roll Number 62

Section A

Subject Design Analysis and Algorithm

Department Artificial Intelligence

Practical No-10
Aim: To implement and analyze the time complexity of Breadth First Search.

Theory: Breadth First Search (BFS) is a technique for traversing a finite graph.
BFS visits the neighbour vertices before visiting the child vertices, and a queue is
used in the search process. This algorithm is often used to find the shortest path
from one vertex to another.

● Here we start traversing from a selected node (source node) and traverse the
graph layer/level wise thus exploring the neighbour nodes (nodes which are
directly connected to the source node). We must move to the next layer/level
only after traversing the current layer/level completely.
● In short:
i. Move horizontally and visit all the nodes of the current layer/level.
ii. Move to the next layer.

Algorithm: The algorithm starts with examining the source node and all of its
neighbours. In the next step, the neighbours of the nearest node of the source node
are explored. The algorithm then explores all neighbours of all the nodes and
ensures that each node is visited exactly once and no node is visited twice.

STEP 1: Start by putting any one of the graph vertices into the queue.
STEP 2: Take the front item in the queue and add it to the visited list.

STEP 3: Create the list of that vertex adjacent node. Add the ones which are not in
the visited list to the back of the queue.

STEP 4: Keep repeating steps 2 and 3 until the queue is empty.

Practice:

Complexity of Breadth First Search:


● The time complexity of the BFS algorithm is represented in the form of O(V
+ E), where V is the number of nodes and E is the number of edges.
● The space complexity of the algorithm is O(V).

Conclusion: I have successfully implemented and analyzed the time complexity


of Breadth First Search.

You might also like