Posts

CODE

Image
 1.Implementation of BFS  from collections import deque graph = {     'A': ['B', 'C'],     'B': ['C', 'D', 'E'],     'C': ['F'],     'D': [],     'E': ['F'],     'F': [] } def bfs(graph, start_node, key):     visited = set()     queue = deque([start_node])     print("Breadth First Search started")     while queue:         node = queue.popleft()         if node == key:             print(node, "Found")             return         if node not in visited:             print(node, end=" -> ")             visited.add(node)             for i in graph[node]:                 if i not in visited:             ...

AI LAB

Image
 1.Implementation of BFS 2.Implementation of DFS 3.Implementation of A* Tic-Tac-Toe

DS_LAB- Exam NOTES

 EXP 1: C program to traverse an array #include < stdio.h > int main () {     int arr [ 5 ] = { 10 , 20 , 30 , 40 , 50 };  // Declare and initialize an array     int i ;     printf (" The elements of the array are: \n ");     for ( i = 0 ; i < 5 ; i ++ ) {         printf (" Element at index %d : %d \n ", i , arr [ i ]);     }     return 0 ; } Exp: 2 C program to insert an element into an array #include < stdio.h > int main () {     int arr [ 100 ], n , i , pos , value ;     // Get number of elements     printf (" Enter number of elements in array: ");     scanf (" %d ", & n );     // Get elements from user     printf (" Enter %d elements: \n ", n );     for ( i = 0 ; i < n ; i ++ ) {         scanf (" %d ", & arr [ i ]);     }     //...

Popular posts from this blog

C-Programming of Class 12

C-Program of Class 11