6. {
destroy_tree(p);
}
free(root);
}
void display_tree(struct node *root)
{
if (root != NULL)
{
for (struct node *p = root->leftchild; p != NULL; p = p->next)
{
printf("[%3d, %3d]n", root->id, p->id);
display_tree(p);
}
}
}
Please implement the bfs(struct node *root) function and the necessary queue data structure
using the C programming language to match the intended output and provide the additional
functions, methods and imports used. Problem 1 [2 pt]. Attached is a C language program
search.c. It has functions: - void dfs(struct node * root, int source): prints all the nodes in a tree in
depth first search order. - void bfs (struct node * root, int source): prints all the nodes in a tree in
breadth first search order. The bfs function doesn't work, and its present form implements dfs.
Correct the bfs function, by replacing the stack with a queue. You need to define - the data
structure for the queue (struct queue) - write additional functions such as create_queue
destroy_queue queue_add (add a node to the queue) queue_get (get a node from the queue)
queue_size and perhaps others. The output should look something like this: Display Tree [node,
child] [055][[1010][[5,9][[0,3][[,8][[2,][1,7] DFS 016724835910 BFS 053211098476