Professional Documents
Culture Documents
Ai 2
Ai 2
Experiment No:2
TITTLE: Write a Program to implement Uninformed Search Technique: Breadth First Search.
EXERCISE
1) Implement BFS Using python and Prolog.
Ans:
graph = {
'5' : ['3','7'],
'3' : ['2', '4'],
'7' : ['8'],
'2' : [ ],
'4' : ['8'],
'8' : [ ]
}
visited.append(neighbour)
queue.append(neighbour)
# Driver Code
print("Following is the Breadth-First Search")
bfs(visited, graph, '5') # function calling
OUTPUT:
Following is the Breadth-First Search
537248