Write a program to implement Depth First Search (DFS) graph traversal methods.
#include <stdio.h>
int stack[5],top=-1,known[10],n,a[10][10];
void push(int val){
stack[++top]=val;
}
int pop(){
int ver=stack[top--];
printf("%d-> ",ver);
return ver;
}
int stackempty(){
if(top==-1)
return 1;
else
return 0;
}
void dfs(int sv){
push(sv);
known[sv]=1;
while(!stackempty()){
int i;
int v=pop();
for(i=n;i>0;i--){
if(!(!(a[v][i]))&&!(known[i])){
push(i);
known[i]=1;
}
}
}
}
int main(void) {
// your code goes here
int i,j,sv;
printf("\nEnter number of vertices");
scanf("%d",&n);
printf("\n enter %d elements into adjcency matrix",n*n);
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
scanf("%d",&a[i][j]);
}
}
printf("\n enter Start vertex");
scanf("%d",&sv);
dfs(sv);
return 0;
}
1) Write a C program that uses functions to perform the following on Singly Linked List: i) Creation ii) Insertion iii) Deletion iv) TraversalView Solution
2) Write a program that uses functions to perform the following operations on Doubly Linked List.: i) Creation ii) Insertion iii) Deletion iv) TraversalView Solution
3) Write a program that uses functions to perform the following operations on Circular Linked List.: i) Creation ii) Insertion iii) Deletion iv) TraversalView Solution
4) Write a program that implement Stack (its operations) using ArraysView Solution
5) Write a program that implement Stack (its operations) using PointersView Solution
6) Write a program that implement Queue (its operations) using ArraysView Solution
7) Write a program that implement Queue (its operations) using PointersView Solution
8) Write a program that implements Bubble Sort Method to sort a given list of integers in ascending order.View Solution
9) Write a program that implements Selection Sort Method to sort a given list of integers in ascending order.View Solution
10) Write a program that implements Insertion Sort Method to sort a given list of integers in ascending order.View Solution
11) Write a program that use both recursive and non recursive functions to perform Linear search operations for a Key value in a given list of integers.View Solution
12) Write a program that use both recursive and non recursive functions to perform Binary search operations for a Key value in a given list of integers.View Solution
13) Write a program to implement the tree traversal methods.View Solution
14) Write a program to implement Depth First Search (DFS) graph traversal methods.View Solution
15) Write a program to implement Breadth First Search (BFS) graph traversal methods.View Solution