You are on page 1of 5

Student Name: Pravesh Azan UID: 19BCS2979

Branch: Section/Group : A

Semester: 5 Date of Performance: 17/01/2023

Subject Name: AIML LAB Subject Code: CSP303

EXPERIMENT NO 3

1. Aim/Overview of the practical:

Write a python program to implement BREADTH FIRST SEARCH


TRAVERSAL
2. Task to be done/ Which logistics used:

To implement breadth first search traversal using python

3. S/W Requirement :

Laptop/PC , Python Complier

4. Steps for experiment/practical/Code:

from collections import deque

# create a graph represented by an adjacency list


graph = {
"A": ["B", "C"],
"B": ["A", "D", "E"],
"C": ["A", "F"],
"D": ["B"],
"E": ["B", "F"],
"F": ["C", "E"]
}

def bfs(graph, start):


visited = set()
queue = deque([start])
while queue:
vertex = queue.popleft()
if vertex not in visited:
visited.add(vertex)
queue.extend(graph[vertex])
return visited

print(bfs(graph, "A"))

5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks

1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)

3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:

You might also like