Question

In: Computer Science

Use the weighted digraph for problems below: V = {a, b, c, d, e, f, g,...


  1. Use the weighted digraph for problems below:
       V = {a, b, c, d, e, f, g, h}
    
       E = {(a,b,6), (a,d,3), (b,c,2), (b,e,5), (c,f,4), (d,e,9), (d,g,1), (e,f,7), (e,g,8), (e,h,2), (f,h,4), (g,h,4)}
    
    
    
  2. (3 pts.) What is the length of the longest path from a to h? Show the path!
  3. (2 pts.) Does the graph contain a cycle? Justify your answer!
  4. (3 pts.) Give the adjacency matrix for the graph.
  5. (4 pts.) Provide the order in which nodes would be visited in a depth-first traversal starting at a. State any assumptions you made in arriving at your answer.
  6. (4 pts.) Provide the order in which nodes would be visited in a breadth-first traversal starting at a. State any assumptions you made in arriving at your answer.
  7. (4 pts.) Perform Dijkstra's algorithm to obtain the shortest path from a to every other vertex in the graph. Show your work!

Solutions

Expert Solution

Given undirected graph

The length of the longest path from a to h is a - 6   b - 5   e - 9   d - 1   g - 4   h = 25(6+5+9+1+4)

The given graph contain a so many cycles a-b-e-g-d-a, b-c-f-h-e-b,a-b-c-f-h-e-g-d-a

Adjacency Matrix Representation of a graph

DFS: Step 1:                                        

Output: a b

Step 2:                                 

Output: a b c

Step 3:                            

Output: a b c f

Step 4:               

Output: a b c f h

Step 5:   

                                     

Output: a b c f h g

Step 6 :    

                             

Output: a b c f h g e

Step 7:                             

Output: a b c f h g e d

The DFS of a graph starting at vertex a is a b c f h g e d

DFS Tree as follows

         

BFS: Step 1:                                        

Output: a b

Step 2:                                 

Output: a b d

Step 3:                            

Output: a b d c

Step 4:               

Output: a b d c e

Step 5:                                        

Output: a b d c e g

Step 6 :                                 

Output: a b d c e g f

Step 7:                             

Output: a b d c e g f h

The BFS of a graph starting at vertex a is a b d c e g f h

BFS Tree as follows

         


Related Solutions

Use the table for the question(s) below. Combination A B C D E F G Vaccine...
Use the table for the question(s) below. Combination A B C D E F G Vaccine doses (millions) 6 5 4 3 2 1 0 Guns 0 10,000 19,000 24,000 28,000 30,000 31,000 In the table above, the opportunity cost of vaccines remains constant as more vaccines are produced. remains constant as more guns are produced. increases as more guns are produced. increases as more vaccines are produced. decreases as more vaccines are produced. If the economy is currently producing...
If there are 7 total notes C, D, E, F, G, A, and B and if...
If there are 7 total notes C, D, E, F, G, A, and B and if a five-note melody is selected at random (so that all melodies counted in part (a) are equally likely to be chosen), what is the probability that the melody will include exactly two “A” notes, but no other repeated notes? (A few allowable examples: AACEG, ACAEG, DFACA, EAABC, etc.)
Consider the cities B,C,D,E,F,G The costs of the possible roads between cities are given below: c(B,F)...
Consider the cities B,C,D,E,F,G The costs of the possible roads between cities are given below: c(B,F) = 11 c(B,G) = 10 c(C,G) = 8 c(D,E) = 12 c(D,F) = 13 c(E,F) = 9 c(E,G ) = 7 What is the minimum cost to build a road system that connects all the cities?
Seven people (A,B,C,D,E, F, and G) are seated in a row. Suppose A,B, and C are...
Seven people (A,B,C,D,E, F, and G) are seated in a row. Suppose A,B, and C are freshmen, D and E are sophomores and F and G are juniors. How many arrangements are possible if: (a) D and F must sit together? (b) A and C must not sit together? (c) All freshmen must sit together? (d) All freshmen must sit together, all sophomores must sit together, and all juniors must sit together? (e) Exactly two people sit between A and...
(a) (f ∘ g)(3) (b) g(f(2)) (c) g(f(5)) (d) (f ∘ g)(−3) (e) (g ∘ f)(−1) (f) f(g(−1))
(a)    (f ∘ g)(3) (b)    g(f(2)) (c)    g(f(5)) (d)    (f ∘ g)(−3) (e)    (g ∘ f)(−1) (f)    f(g(−1))  
A restaurant has dishes A, B, C, D, E, F and G The owners anticipate that...
A restaurant has dishes A, B, C, D, E, F and G The owners anticipate that dishes will be ordered in the following proportions: 30% (A), 15% (B), 20% (C), 5% (D), 8% (E), 12% (F) and 10% (G). The number of orders placed during the first two days of business was 75 (A), 60 (B), 50 (C), 14 (D), 20 (E), 40 (F), and 41 (G).    State and conduct the appropriate hypothesis test to determine whether there is...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of functional dependencies: FD= {{B}—> {A}, {G}—> {D, H}, {C, H}—> {E}, {B, D}—> {F}, {D}—>{C}, {C}—> {G}} 1) Draw FD using the diagrammatic notation. 2) What are all candidate keys for R? 3) If delete {C}—>{G} and change {C, H}—> {E} to {C, H}—> {E, G}, what are all candidate keys for R
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what proportion of the progeny will phenotypically resemble the first parent? b) what proportion of the progeny will genotypically resemble neither parent?
Please fill in the blanks (values of A, B, C, D, E, F, G, H, I...
Please fill in the blanks (values of A, B, C, D, E, F, G, H, I , J) for the following financial statements. The firm’s tax rate is 35.3%. Income Statement for Fiscal Year 2015 Sales 2,000 Cost of goods sold 1,500 Gross margin 500 Selling and general expenses 300 Operating income 200 Interest income 5 205 Interest expense 21 Restructuring charges 14 Income before tax 170 Income tax 60 Net income J Balance Sheet, Year 2014 and Year 2015...
In how many ways can 7 people { A, B, C, D, E, F, G }...
In how many ways can 7 people { A, B, C, D, E, F, G } be seated at a round table if (a) A and B must not sit next to each other; (b) C, D, and E must sit together (i.e., no other person can sit between any of these three)? (c) A and B must sit together, but neither can be seated next to C or D. Consider each of these separately. For (c) you may NOT...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT