Question
!!!Please read carefully then answer of this question!!! This Given C programing code is in DFS(Depth First Search). You have to Implement BFS(Breadth First Search)
!!!Please read carefully then answer of this question!!!
This Given C programing code is in DFS(Depth First Search). You have to Implement BFS(Breadth First Search) in the given C programing code. You can't give a new code. You have to edit the code and simply Implement BFS(Breadth First Search) in C program.
You have to answer the question in C program. Any other programming language is not acceptable.
Code -
#include
void dfs(int g[100][100], int visited[], int source, int n);
int main() { int vertex,i,j;
printf("enter number of vertex:"); scanf("%d", &vertex); int arr[100][100], visited[100];
for (i=0; i } printf("graph values: "); for(i=0; i dfs(arr, visited, 3, vertex); return 0; } void dfs(int g[][100], int visited[], int source, int n)//n: number of vertices, k: node { int i; visited[source] = 1; printf("%c visited ",65+source); for(i = 0; i< n; i++) { if(g[source][i] == 1 && visited[i] == 0) dfs(g, visited, i, n); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started