Question: For the digraph given, implement the pseudo algorithms of Bread-First Search (Traversal) and Depth-First Search (Traversal) in Java or C++. Your implementation should follow the

 For the digraph given, implement the pseudo algorithms of Bread-First Search

For the digraph given, implement the pseudo algorithms of Bread-First Search (Traversal) and Depth-First Search (Traversal) in Java or C++. Your implementation should follow the pseudocode provided in the lecture and also as shown below. Use your variables in the implementation. Each must be a separate method. DO NOT COPY SOMEBODY ELSE'S CODE! To complete and test the implementation, you will need to a. Make an adjacency-list or adjacency-matrix to save information about nodes and edges. b. Display the results in the sequence of each of the nodes traversed based on the search 1. (traversal) algorithm. breadthFirstsearch() for all vertices u num (u)0: edges-null; while there is a vertex v such that num(v)0 num ( v ) =1++ ; enqueue (V); while queue is not empty v - dequeue) for all vertices u adjacent to v DFS (v) num (v)i++ for all vertices u adjacent to v if num (u) is 0 if num (u) is 0 attach edge (uv) to edges; DFS (u) num ( u ) =i++ ; enqueue (u); attach edge(vu) to edges; depthFirstsearch () output edges; for all vertices v niin (v) =0; edgesnull; while there is a vertex v such that num (v) is 0 DES (v) output edges

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!