DAA Exp-5
DAA Exp-5
DAA Exp-5
Design and Implement C/C++ Program to obtain Topological Ordering of vertices in a given digraph.
Program:
#include<stdio.h>
int temp[10],k=0;
int i,j;
if(id[i]==0)
id[i]=-1;
temp[++k]=i;
id[j]--;
i=0;
void main()
int a[10][10],id[10],n,i,j;
id[i]=0;
scanf("%d",&a[i][j]);
if(a[i][j]==1)
id[j]++;
sort(a,id,n);
if(k!=n)
else
printf("%d ",temp[i]);
OUTPUT
Additional Program: Insertion Sort
Program:
#include <stdio.h>
int i, key, j;
key = arr[i];
j = i - 1;
arr[j + 1] = arr[j];
j = j - 1;
arr[j + 1] = key;
int main()
int i;
int n = 5;
insertionSort(arr, n);
printf("%d\n", arr[i]);
return 0;