Question

1 Graph Search Consider the following graph G. 1.1 Draw the DFS tree for G when starting in node 0. Assume that the adjacency

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The adjacency list for the given tree is :

OL Nחרר 00 |------- Nחרר -1] - Nחדר [os - -- --- אחרר os - ES]- אחדו 3-E- אחדר ].-- אחרר 9]--- N - - - [ on חרר [s]- אחדד 9-פ

The discovery/ finish time is represented as _ / _ and the discovery time of the source node 0 is taken as 0.

Source is given as node 0.

Initially, stack contains 0.

Neighbour of node 0 is node 2.

phpXApX2I.png

Push 2.

Stack : 0 2

Neighbour of node 2 is node 3.

phpnXsj69.png

Push 3.

Stack : 0 2 3

Neighbour of node 3 is node 7.

phpk661Tq.png

Push 7.

Stack : 0 2 3 7

07 0 3/4

Node 7 has no neighbours.

Pop 7.

Stack : 0 2 3.

Backtrack from node 7 to node 3.

Node 3 has no unvisited neighbours.

Pop 3.

Stack : 0 2 3.

Backtrack from node 3 to node 2.

Neighbour of node 2 is node 5.

01 215 617 14

Push 5

Stack : 0 2 5

Node 5 has no unvisited neighbours.

Pop 5.

Stack : 0 2

Neighbour of node 2 is node 6.

01 215 617 1314

Push 6

Stack : 0 2 6

Neighbour of node 6 is node 10.

215 617 1314

Push 10.

Stack : 0 2 6 10

Neighbour of node 10 is node 11.

215 71314 101_

Push 11.

Stack : 0 2 6 10 11

Node 11 has no unvisited neighbour.

215 617, 314 10/11

Pop 11.

Stack : 0 2 6 10

Backtrack from node 11 to node 10.

Node 10 has no unvisited neighbour.

215 官JI 314 1912 10/11

Pop 10.

Stack : 0 2 6

Backtrack from node 10 to node 6.

Node 6 has no unvisited neighbour.

215 8113 314 1912 10/11 10

Pop 6.

Stack : 0 2

Backtrack from node 6 to node 2.

Node 2 has no unvisited neighbour.

01 114 215 8/13 314 197/12 10/11

Pop 2.

Stack : 0

Neighbour of node 0 is node 1.

01. 1/14 215 8/13 | 314 1 9/12 10/11

Push 1.

Stack : 0 1.

Neigbour of node 1 is node 4.

01 1/14 215 3/4 9/12 10/11 7

Push 4.

Stack : 0 1 4

Neighbour of node 4 is node 8.

1114 215 33 151 8113 734 171 10/11

Push 8.

Stack : 0 1 4 8

Neighbour of node 8 is node 9.

1114 215 32 8113 71314 161 1711 19712 10/11

Push 9.

Stack : 0 1 4 8 9.

Node 9 has no unvisited neighbour.

1/14 215 3/4 19/12 17/_ 10/11 18 | 19 6666 10

Pop 9.

Stack : 0 1 4 8

Backtrack from node 9 to node 8.

Node 8 has no unvisited neighbour.

1114 215 8113 71314 461 , 17120 18/19 19/12 10/11

Pop 8.

Stack : 0 1 4

Node 4 has no unvisited neighbour.

07 1114 215 13 151 314 16121/ 9/12 17120 18 19 10/11 业 10

Pop 4.

Stack : 0 1.

Node 1 has no unvisited neighbour.

01 1/14 215 15122 8113 617 1314 16121/ 17120 18119 19/12 业 10/11

Pop 1.

Stack : 0

Node 0 has no unvisited neighbour.

0/23 114 215 | 15122 8/13 314 16/ 17120 18 19 1912 10/11 业

Pop 0.

Stack is empty.

Therefore, the DFS tree from the given directed graph is :

0/23 114 215 | 15122 8/13 314 16/ 17120 18 19 1912 10/11 业

The discovery time and finish time of the nodes in the DFS tree is :

0/23 1/14 2/5 2 15/ 22 8 / 13 617 3/4 7 16/21 17/2018/19 9/12 10/11

Add a comment
Know the answer?
Add Answer to:
1 Graph Search Consider the following graph G. 1.1 Draw the DFS tree for G when...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. (8 points-7+1) Figure 4 shows an undirected graph G. Assume that the adjacency list lists the ...

    3. (8 points-7+1) Figure 4 shows an undirected graph G. Assume that the adjacency list lists the edges in alphabetical order. Figure 3: Graph for P3 (a) Apply depth first search (DFS) to graph G, and show the discovery and finish times of each vertex. In the main-loop of DFS, check the vertices in alphabetical the form dsc/fin, where dsc is the discovery time and fin is the finish time. (b) Draw the DFS tree obtained. 3. (8 points-7+1) Figure...

  • 3. Given a directed graph G < V E >, we define its transpose Gr < V.E1 > to be the graph such tha...

    3. Given a directed graph G < V E >, we define its transpose Gr < V.E1 > to be the graph such that ET-{ < v, u >:< u, v >EE). In other words, GT has the same number of edges as in G, but the directions of the edges are reversed. Draw the transpose of the following graph: ta Perform DFS on the original graph G, and write down the start and finish times for each vertex in...

  • Consider the following directed graph for each of the problems: 1. Perform a breadth-first search on...

    Consider the following directed graph for each of the problems: 1. Perform a breadth-first search on the graph assuming that the vertices and adjacency lists are listed in alphabetical order. Show the breadth-first search tree that is generated. 2. Perform a depth-first search on the graph assuming that the vertices and adjacency lists are listed in alphabetical order. Classify each edge as tree, back or cross edge. Label each vertex with its start and finish time. 3. Remove all the...

  • Q2. Show the execution trace of DFS on the following directed graph. You must show discovery...

    Q2. Show the execution trace of DFS on the following directed graph. You must show discovery time v.d, finish time v.f, and the v.color for each node as the algorithm progresses. Indicate all tree edges, back edges, forward edges, and cross edges when the final DFS forest is constructed. Assume that the edges going out from a vertex are processed in alphabetical order and that each adjacency list is ordered alphabetically.

  • Problem 2 [10 points] Depth-First Search Write inside each vertex in the following graph the discovery...

    Problem 2 [10 points] Depth-First Search Write inside each vertex in the following graph the discovery and finishing times in the format discovery/finish. Assume DFS considers the vertices in alphabetical order (A,B,C,....X,Y,Z), and assume that each adjacency list is ordered alphabetically W 1/ х у

  • Show the operation of depth-first search (DFS) on the graph of Figure 1 starting from vertex...

    Show the operation of depth-first search (DFS) on the graph of Figure 1 starting from vertex q. Always process vertices in alphabetical order. Show the discovery and finish times for each vertex, and the classification of each edge. (b) A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first search (BFS) tree can also be used to classify the edges reachable from the source of the search into the same four categories....

  • Give the adjacency matrix representation and the adjacency lists representation for the graph G_1. Assume that...

    Give the adjacency matrix representation and the adjacency lists representation for the graph G_1. Assume that vertices (e.g., in adjacency lists) are ordered alphabetically. For the following problems, assume that vertices are ordered alphabetically in the adjacency lists (thus you will visit adjacent vertices in alphabetical order). Execute a Breadth-First Search on the graph G_1, starting on vertex a. Specifiy the visit times for each node of the graph. Execute a Depth-First Search on the graph G_1 starting on vertex...

  • Please help me with 2 (c), thank you!!! Figure 2: 4 10 Figure 3:1 4 Problems 1. Trace BFS on the following graphs. For...

    Please help me with 2 (c), thank you!!! Figure 2: 4 10 Figure 3:1 4 Problems 1. Trace BFS on the following graphs. For each vertex, record its color, parent, and distance fields, draw the resulting BFS tree, and determine the order in which vertices are added to the Queue. Process adjacency lists in ascending numerical order. a. The graph in figure 1, with 1 as the source. b. The directed graph in figure 2 with 1 as source. 2....

  • Execute DFS on the graph below, starting in node a. Whenever you have a choice which...

    Execute DFS on the graph below, starting in node a. Whenever you have a choice which vertex to visit next, choose the next vertex in the adjacency list of the vertex (e.g., when you have reached node e, you must first try to visit node f, then g, and then . Indicate the outcome of the algorithm by labeling the edges of the graph either as T (tree edge) F (forward edge), B (back edge), or C (cross edge). Label...

  • Draw the DFS search tree with starting vertex E and break ties alphabetically. Assuming unit edge...

    Draw the DFS search tree with starting vertex E and break ties alphabetically. Assuming unit edge length (i.e., ignore edge weight), draw the BFS search tree with starting vertex E and break ties alphabetically. Suppose the Dijkstras algorithm is run on the graph with starting vertex E: (i) draw a table showing the intermediate distance values of all vertices at each iteration of the algorithm; (ii) show the final shortest-path tree.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT