Question: Please help to write a C program on the following question 4 part (a) and (b) that is able to run on CodeBlocks A pseudocode
Please help to write a C program on the following question 4 part (a) and (b) that is able to run on CodeBlocks

A pseudocode of the depth-first search algorithm is as follows Algorithm DFS(G) Input: Graph G-(V,E) Output: Graph G with its vertices marked with consecutive integers in the order they ve been encountered by DFS traversal and the number of connected components count 0 mark each vertex with 0 (unvisited) for each vertex ve Vdo if v is marked with 0 then componentcomponent + 1 dfs(v) dfs(v) visits recursively all unvisited vertices connected to v and assigns them the numbers in the order they are encountered via global variable count' count count 1 mark v with count for each vertex w adjacent to v do if w is marked with 0 then dfs(w) Note: 1. The variable count gives the sequence number of which a node is visited t gives the number of connected components in 2. The variable the graph. If component 1, the graph is connected; else there are more than one disconnected components. 4. Additional Implementation Requirements a) Given a depth-first search tree T, the set of edges in T are referred to as "tree edges" while those not in T are referred to as "back edges". Modify the implementation of the Depth-First Search algorithm to print out the set of tree edges and the set of back edges for the following graph. 10 1 1 0 0 1 0 2 1 0 1 0 0 0 0 31 01 0 0 1 4001 0 0 0 0 5 0 0 0 0 0 1 6 1 0 0 0 0 1 70 0 10 1 0 b) One application of the depth-first search is for checking acyclicity of a graph. If there is a back edge (an edge not in the DFS tree T) from some vertex u to its ancestor v in T, the graph has a cycle that comprises the path from v to u via a sequence of tree edges in T followed by the back edge from u to v. Modify your program to determine if there is a cycle in each connected components of a given graph. Test your program with the graph given in part(a) above. A pseudocode of the depth-first search algorithm is as follows Algorithm DFS(G) Input: Graph G-(V,E) Output: Graph G with its vertices marked with consecutive integers in the order they ve been encountered by DFS traversal and the number of connected components count 0 mark each vertex with 0 (unvisited) for each vertex ve Vdo if v is marked with 0 then componentcomponent + 1 dfs(v) dfs(v) visits recursively all unvisited vertices connected to v and assigns them the numbers in the order they are encountered via global variable count' count count 1 mark v with count for each vertex w adjacent to v do if w is marked with 0 then dfs(w) Note: 1. The variable count gives the sequence number of which a node is visited t gives the number of connected components in 2. The variable the graph. If component 1, the graph is connected; else there are more than one disconnected components. 4. Additional Implementation Requirements a) Given a depth-first search tree T, the set of edges in T are referred to as "tree edges" while those not in T are referred to as "back edges". Modify the implementation of the Depth-First Search algorithm to print out the set of tree edges and the set of back edges for the following graph. 10 1 1 0 0 1 0 2 1 0 1 0 0 0 0 31 01 0 0 1 4001 0 0 0 0 5 0 0 0 0 0 1 6 1 0 0 0 0 1 70 0 10 1 0 b) One application of the depth-first search is for checking acyclicity of a graph. If there is a back edge (an edge not in the DFS tree T) from some vertex u to its ancestor v in T, the graph has a cycle that comprises the path from v to u via a sequence of tree edges in T followed by the back edge from u to v. Modify your program to determine if there is a cycle in each connected components of a given graph. Test your program with the graph given in part(a) above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
