Posts

Showing posts from October, 2019

AI Full Practical Code (Missionaries and Cannibals problem, implement depth first search algorithm, tic-tac-toe game)

1 (A): Write a program to implement depth first search algorithm. // PYTHON CODE// graph1= {'A':set(['B','C']),     'B':set(['A','D','E']),     'C':set(['A','F']),     'D':set(['B']),     'E':set(['B','F']),     'F':set(['C','E'])    } def dfs(graph,node,visited):     if node not in visited:       visited.append(node)       for n in graph[node]:          dfs(graph,n,visited)     return visited visited= dfs(graph1,'A',[]) print(visited) ************************************END************************************ ************************************END************************************ 1(b): Write a program to implement breadth first search algorithm. //PYTHON CODE// graph = {'A': ['B', 'C', 'E'],          'B': ['A','D', 'E'],          'C&#