AI - Programs KP Print
AI - Programs KP Print
Roll No.:- 69
Div:-B
Title:- Implement DFS and BFS Algorithm. Use and Undirected Graph and develop a Recursive
Algorithm for searching all the vertices of the graph or tree data structure.
Program :-
Breadth First Search(BFS):-
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : [],
'E' : ['F'],
'F' : []
}
visited = [] # List to keep track of visited nodes.
queue = [] #Initialize a queue
print ("Hello")
def bfs(visited, graph, node):
visited.append(node)
queue.append(node)
while queue:
s = queue.pop(0)
print (s, end = " ")
print ("Hello")
Title:- Implement A star Algorithm for any game search problem Program :-
A* Algorithm
adjacency_list = {
'A': [('B', 1), ('C', 3), ('D', 7)],
'B': [('D', 5)],
'C': [('D', 12)]
}
graph1 = Graph(adjacency_list)
graph1.a_star_algorithm('A', 'D')
Name:-Kamlesh Pawar
Roll No.:- 69
Div:-B
Title:- Implement a solution for a constraint satisfaction problem using branch and bound and
bracktracking for n-queens problem or a graph coloring problem
Program :-
n-queens problem
global N N =
4
True
if isSafe(board, i, col):
# Place this queen in board[i][col] board[i][col] = 1
Title:- Develop an elementary chatbot for any suitable customer interaction application
Program :-
Chatbot Program
def remind_name():
print('Please, remind me your name.') name =
input()
print("What a great name you have, {0}!".format(name))
def guess_age():
print('Let me guess your age.')
print('Enter remainders of dividing your age by 3, 5 and 7.')
def count():
print('Now I will prove to you that I can count to any number you want.')
num = int(input())
counter = 0
while counter <= num: print("{0}
!".format(counter)) counter += 1
def test():
print("Let's test your programming knowledge.") print("Why do we
use methods?")
print("1. To repeat a statement multiple times.")
print("2. To decompose a program into several small subroutines.") print("3. To
determine the execution time of a program.")
print("4. To interrupt the execution of a program.")
answer = 2
guess = int(input()) while guess
!= answer:
print("Please, try again.") guess =
int(input())
def end():
print('Congratulations, have a nice day!') print('. ')
print('................................................. ')
print('................................................. ')
input()