AOA Lab
AOA Lab
AOA Lab
AOA LAB
2021pceitashish012@poornima.org Switch accounts
Not shared
3.
a. Obtain the Topological ordering of vertices in a given digraph.
b. Computethe transitive closure of a given directed graph using
Warshall's algorithm.
Your answer
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 1/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 2/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 3/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 4/29
12/18/23, 5:07 PM AOALAB
3.8.PART ONE
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 5/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 6/29
12/18/23, 5:07 PM AOALAB
3..B.PART TWO
Your answer
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 7/29
12/18/23, 5:07 PM AOALAB
CODE part 1
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 8/29
12/18/23, 5:07 PM AOALAB
#include<stdio.h>
#include<conio.h>
#define HEFIN ITY 9999
1
#d.ef"ine MAX 10
int main()
{
int G[MAX] [MAX],,i.,.j, n,.u;,
printf( "Enter no. of vertices:");.
scanf( "%d" ,&n) ;.
prirrtf(''\nEllter the adjacency matrix: \n");
for(i:iO;.i<n;.i++)
for(j=O_;.j <n_;.j++)
scanf( "%d" ,&G[i] [ j]) ;.
prirrtf(''\nEllter the st,;wting· node:");,
scanf ("%d", &u) ;,
dij kstra (G, n, u) ;,
return 0;.
}
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 9/29
12/18/23, 5:07 PM AOALAB
LIJLLi:lllU= L..L,J=Lo:,, LL. Li:lr"UlUli..l .J L..LJ'
pred [ i] =st:cirtnode;.
vi.sited [ i] =0;.
}
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 10/29
12/18/23, 5:07 PM AOALAB
CODE part 2
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 11/29
12/18/23, 5:07 PM AOALAB
di.stance [ st.artnode
J=:O; visited [startnode]
=1; co1.mt=i;
while(count<n-1)
{
mi11dista11ce=INIFINITY;
/ /nextnode gives the Ro,cle at minimum dist.a
He for(i=O;i<n;i++)
if( di.stance [ i] <min distance&&!vi.sit.ed[ i])
{
mindistBnce=distBnce[i];
nextnode=i;
}
//check if a better p,ath exists through nextnode
visited [ nextnode] =1.;.
for(i=O;i<n;i++)
if(!vi.sited[i])
if(mindistance+cost[nex:tnode][i]<distance[i])
{
distance [ i] =mindist.ance+cost[ nextnode] [ i];
pred[i]=nextnode;
}
COi.Hilt++;
}
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 12/29
12/18/23, 5:07 PM AOALAB
Your answer
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 13/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 14/29
12/18/23, 5:07 PM AOALAB
Your answer
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 15/29
12/18/23, 5:07 PM AOALAB
Queens problem 1
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 16/29
12/18/23, 5:07 PM AOALAB
Queens problem 2
Your answer
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 17/29
12/18/23, 5:07 PM AOALAB
DFS1
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 18/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 19/29
12/18/23, 5:07 PM AOALAB
DFS2
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 20/29
12/18/23, 5:07 PM AOALAB
1. Print all the nodes reachable from a given starting node in a digraph using
BFS
method
Your answer
BFS code1
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 21/29
12/18/23, 5:07 PM AOALAB
BFS code2
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 22/29
12/18/23, 5:07 PM AOALAB
BFS code 3
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 23/29
12/18/23, 5:07 PM AOALAB
BFS code4
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 24/29
12/18/23, 5:07 PM AOALAB
BFS code5
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 25/29
12/18/23, 5:07 PM AOALAB
BFS CODES
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 26/29
12/18/23, 5:07 PM AOALAB
BFS code6
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 27/29
12/18/23, 5:07 PM AOALAB
BFS code7
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 28/29
12/18/23, 5:07 PM AOALAB
https://docs.google.com/forms/d/e/1FAlpQLSdbd-QdMzpwKO9RjHrKqizKGX2Mo-Oh3e2_WIStw2O1KVzAIQ/viewform?pli=1 29/29