Question

In: Computer Science

Show that a breadth-first spanning tree contains the shortest paths be- tween the root to every...

Show that a breadth-first spanning tree contains the shortest paths be- tween the root to every other vertex.

Solutions

Expert Solution

Let us Consider the Following weighted graph

Let us consider a is the Root then BFS of a graph is as follows

BFS: Step 1:                                                

Output:  a b

Step 2:               

                  

Output: a b e

Step 3:               

              

Output: a b e g

Step 4:     

Output: a b e g c

Step 5:             

                           

Output: a b e g c f

Step 6 :      

Output: a b e g c f d   

Step 7:       

Output: a b e g c f d h

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

BFS Tree as follows

Kruskal’s Algorithm to find the Minimum Cost Spanning Tree (MCST) of a graph G as follows:

Here consider those edges in each step which are minimum and doesnot form Loops

Edge: Cost:

a - e 1   

a - b 2

a - g 3

b - c 3

b - e 3

e - f 4

e - g 4

f - h 5

c - f 7

c - e 8

c - d 9

d - f 11

Step 1:

Step 2:

  

Step 3:

Step 4:

  

Step 5:

Step 6 :

  

Step 7:

For n- Vertices we get (n-1) Edges in MCST. Here in graph having 8 Vertices so we get 7 Edges

Which is Required MCST of a graph using Kruskal’s Algorithm

Note:

From the above Minimum Cost Spanning Tree (MCST) of a graph obtained in Kruskal’s Algorithm and Breadth First Search (BFS) Algoritm both are same
so we can say that breadth-first spanning tree contains the shortest paths be- tween the root to every other vertex.

  


Related Solutions

Consider the following splay tree: Show the paths from root to node 12, 10, 9, 5,...
Consider the following splay tree: Show the paths from root to node 12, 10, 9, 5, and 1 after search node 3. (Sample answer: for the above splay tree, the path from root to node 9 can be expressed as 10, 4, 6, 8, 9.) The path from root to node 12:Question Blank.The path from root to node 10:Question Blank.The path from root to node 9:Question Blank.The path from root to node 5:Question Blank.The path from root to node 1:Question...
Show that a graph T is a tree if and only if for every two vertices...
Show that a graph T is a tree if and only if for every two vertices x, y ∈ V (T), there exists exactly one path from x to y.
Show that every sequence contains a monotone subsequence and explain how this furnished a new proof...
Show that every sequence contains a monotone subsequence and explain how this furnished a new proof of the Bolzano-Weierstrass Theorem.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT