Question: Given the graph below, answer the following questions. 2 A) Represent this graph as an adjacency list. 0 B) Represent this graph as an
Given the graph below, answer the following questions. 2 A) Represent this graph as an adjacency list. 0 B) Represent this graph as an adjacency matrix. 3 C) What is the ordering of nodes If we run Graph DFS starting on node 1? Assume we visit the smallest neighbour first. D) Write your Java code(submit a java file) to implement the DFS for graph traversal using the adjacency matrix (either recursive or iterative). For the test case, you can directly use the above example. And you should call the DFS function several times with different starting points to show the different traversal orders. DFS(graph, 0); // one possible output likes 0 DFS(graph, 1); // one possible output likes 1 0 243 DFS(graph, 2); // ... DFS (graph, 3); // ... DFS(graph, 4); // ...
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
