Question: Do it carefully solve it fast please Implement bfs on the attached source code :- #include void createMatrix(int graph[100][100], int n); void printMatrix(int graph[100][100], int

Do it carefully solve it fast please

Implement bfs on the attached source code :-

#include

void createMatrix(int graph[100][100], int n); void printMatrix(int graph[100][100], int n); void dfs(int graph[100][100], int visited[], int n, int v);

int main() { //printf("hello"); int graph[100][100], n; int visited[100];

printf("enter number of vertices: "); scanf("%d",&n);

createMatrix(graph, n); printMatrix(graph, n);

dfs(graph, visited, n, 1);

return 0; }

void createMatrix(int graph[100][100], int n) { int i, j; for(i = 0; i < n; i++) { for(j = i+1; j < n; j++) { printf("edge between %c & %c: ", 65+i, 65+j); scanf("%d",&graph[i][j]); graph[j][i] = graph[i][j]; } } }

void printMatrix(int graph[100][100], int n) { int i, j; printf(" Adjacency matrix: "); for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { printf("%d\t",graph[i][j]); } printf(" "); } }

void dfs(int graph[100][100], int visited[], int n, int v) { int i; printf("%c visited ",65 + v); visited[v] = 1;

for(i = 0; i < n; i++) { if(graph[v][i] == 1 && visited[i] == 0) { dfs(graph, visited, n, i); } } }

void bfs() { //TODO }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!