1. Suppose you perform a depth first search for the graph { (0,1), (0,2), (0,5), (1,4), (2,3), (3,8), (4,9), (5,6), (5,7), (6,7) }. Let 0 be the source. Assume vertices in adjacency list are ordered smallest int to largest int.
A. Show the resulting tree (drawing a picture is best, but listing the edges in the tree is also good).
B. Show the non-tree edges (either clearly indicate in picture or list them).
C. List the vertices in order of start time.
D. List the vertices in order of finish time.
2. Suppose you run breadth first search on the same graph.
A. Show the resulting tree (drawing a picture is best, but listing the edges in the tree is also good).
B. Show the non-tree edges (either clearly indicate in picture or list them).
C. For the non-tree edges, indicate whether they connect a node on the same level or on a different level.
D. List the vertices in the order visited (start time).
Trending nowThis is a popular solution!
Step by stepSolved in 6 steps with 2 images
- In this task you will work with an undirected Graph G = {V, E}, where V = {f,p,s,b,l,j,t,c,d} and E = {(1,2), (1,3), (3,8), (4,8), (8,9), (1,7), (2,6), (2,3), (5,6), (6,7), (7,9), (8,1)}. Assume that the nodes are stored in an indexed linear structure (e.g., an array or a vector) numbered consecutively from 1 (node f) to 9 (node d). Run, by hand, a depth-first search (DFS) traversal of the graph G, starting at node p. When choosing which node to visit next amongst the possibilities, choose the one that is next in alphabetical order. Give your answer by listing the edges in the order that DFS will select.arrow_forwardWrite a function in a directed graph represented by adjacency lists that returns true (1) if an edge exists between two provided vertices u and v and false (0) otherwise.arrow_forward1. Run DFS-with-timing on this graph G: give the pre and post number of each vertex. Whenever there is a choice of vertices to explore, always pick the one that is alphabetically first. 2. Draw the meta-graph of G. 3. What is the minimum number of edges you must add to G to make it strongly connected (i.e., it consists of a single connected component after adding these edges)? Give such a set of edges. b.arrow_forward
- A simple directed graph with vertices A,B,C,D,E,F,G has adjacency matrixarrow_forward2. Consider the graph G2(V2, E2) below. 2a. Find the MST of this graph with Kruskal’s algorithm. Draw the MST, and show the table [edge] [w(u, v)] [mark]. 2b. Find the MST of this graph with Prim’s algorithm starting at vertex 'a'. Draw the MST and list the vertices in order you added them to the MST. 2c. Would you get a different MST if you repeat 2b starting at vertex 'e'? Why or why not?arrow_forwardPlease give detailed steps, thank you!arrow_forward
- A. Let G be a graph on 17 vertices. We know that G contains at most one cycle. How many edges can G contain at the most? B. The expression r is written in post-order notation (also referred to as RPN). What value does r evaluate to? r = 1 6 7 + - 5 3 + 2 * +arrow_forwardConstruct all regular graphs that exist for the vertex set V = {1, 2, 3, 4}. For example, G = (V,E0) where E0 = {} is one possible grapharrow_forward