Question

Question 3 (4 marks) For the directed graph below, list the order in which the nine nodes are visited during a depth-first (D

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

ShBFSaeri Enqueae stortiy 2 Deauue from q and psind the dauuadde 3> Add all hild nodes of deaed node to 1> node AueuR the hil

Sleration 2: Degpreue firena quae and enguus fall chilel nodes that are not abldy &ueua: hnb dutput ac teration 3 Deaueue and

Iterstion S Deaueca and enguane chuldl nedes of b that ars nat already enaueud praviandy Oatut achnb Heratien G Degueut and e

Lteration & Degueut eanel enqpee child nedes of 4that nol aeguecd pravinshy are lueue Outpat ach Auene is tmply im enguesed

Layerithms 4n DFS 1 Pabh tre Source nedle n slack Pop pan taak ane pash all hild A ate stack nodes 239 reppes node Prinit the

Jteration 2: Rep and foubh chaildren of s that puniaty not pushid arl b Stack Out put ac Iteration 3: Popp and push childhin

4terahien 5 Pap and pash chilslanafg Stack Output achhg teration 6 Pop and pash children of Stark Output aebhgt Heraten Pop a

Page No.: teration &: Pep and push chillron Stack Output acbhp stack is bat e mpely puh e iatastack nad viited 4terai Pep and

Hope this helps
If you have any doubt feel free to comment
Thank You!!

Add a comment
Know the answer?
Add Answer to:
Question 3 (4 marks) For the directed graph below, list the order in which the nine...
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
  • LAB 1 2 5 7 6 9 3 8 . Write code to implement an adjacency matrix (2d matrix) which represents th...

    JAVA LAB 1 2 5 7 6 9 3 8 . Write code to implement an adjacency matrix (2d matrix) which represents the graph. Your code should contain a function called addEdgelint i, int j). Use this function to add the appropriate edges in your matrix. Write code to implement Depth-First-Search (DFS) and Breadth-First-Search (BFS) of your graph. Let 0 be the source Node . Traverse the graph using DFS, print the Nodes as they are visited. . Traverse the...

  • 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...

  • from collections import defaultdict    # This class represents a directed graph using # adjacency list...

    from collections import defaultdict    # This class represents a directed graph using # adjacency list representation class Graph:        # Constructor     def __init__(self):            # default dictionary to store graph         self.graph = defaultdict(list)        # function to add an edge to graph     def addEdge(self,u,v):         self.graph[u].append(v)        # Function to print a BFS of graph     def BFS(self, s):            # Mark all the vertices as not visited         visited = [False] * (len(self.graph))            # Create a queue for BFS         queue...

  • #include <iostream> #include <queue> using namespace std; class Graph { public: Graph(int n); ~Graph(); void addEdge(int...

    #include <iostream> #include <queue> using namespace std; class Graph { public: Graph(int n); ~Graph(); void addEdge(int src, int tar); void BFTraversal(); void DFTraversal(); void printVertices(); void printEdges(); private: int vertexCount; int edgeCount; bool** adjMat; void BFS(int n, bool marked[]); void DFS(int n, bool marked[]); }; Graph::Graph(int n=0) { vertexCount = n; edgeCount = 0; if(n == 0) adjMat = 0; else { adjMat = new bool* [n]; for(int i=0; i < n; i++) adjMat[i] = new bool [n]; for(int i=0;...

  • The following is an adjacency matrix of a directed graph. Start from vertex D, write down...

    The following is an adjacency matrix of a directed graph. Start from vertex D, write down the order of node visited in Breadth-First- Search (BFS) traversal. (Enter the nodes in order in the following format: [A B C D E F G]) Adjacenc y Matrix ABCDEFG A 1111 000 BO00 0101 C0111010 DO 0 1 0 0 1 1 E 0 1 0 1 000 F 100 1 100 G0000100

  • Based on the following adjacency list representation of a graph (where there are no weights assigned...

    Based on the following adjacency list representation of a graph (where there are no weights assigned to the edges), in which order are the elements of this graph accessed during a BFS traversal starting at node A and DFS traversal starting at node E? A: B, C, D B: A, C, D C: A, B, D D: A, B, C, F E: F, G, H F: D, E, G G: E, F, H H: E, G When doing the traversal,...

  • In Python 3 please Apply Breadth First Search (BFS) to traverse the following graph. Start your...

    In Python 3 please Apply Breadth First Search (BFS) to traverse the following graph. Start your traversal from vertex 0, and write down the order in which vertices will be visited during the traversal. 1 8 6 7 2 9 5 4 3

  • 4. A directed graph is given below. Answer the following questions. When there are multiple vertices...

    4. A directed graph is given below. Answer the following questions. When there are multiple vertices that can be considered for a certain step, always operate on the vertex with the smallest ASCII value first. Note that with this consideration, each question has a unique answer. 1) What is the traversal result using breadth-first search starting from vertex A? 2) What is the traversal result using depth-first search starting from vertex A? thetopologicasing of this graph? 4

  • Consider the graph at right. 17 15 [a] In what order are the vertices visited using...

    Consider the graph at right. 17 15 [a] In what order are the vertices visited using DFS 319 1 starting from vertex a? Where a choice exists, use alphabetical order. What if you use BFS? [b A vertex x is "finished" when the recursive call DFS (x) terminates. In what order are the vertices finished? (This is different from the order in which they are visited, when DFS (x) is called.) [c] In what order are edges added to the...

  • Consider the following directed graph, which is given in adjacency list form and where vertexes have...

    Consider the following directed graph, which is given in adjacency list form and where vertexes have numerical labels: 1: 2, 4, 6 2: 4, 5 3: 1, 2, 6, 9 4: 5 5: 4, 7 6: 1, 5, 7 7: 3, 5 8: 2, 6, 7 9: 1, 7 The first line indicates that the graph contains a directed edge from vertex 1 to vertex 2, from 1 to vertex 4, and 1 to 6, and likewise for subsequent lines....

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