GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
71 views

asked in Algorithms by Active (1.3k points)   | 71 views
I think 11.
s-a-b-c-d gives 10 only
According to ur tree distance between s and d is 10 while it should be 7

1 Answer

+6 votes
Best answer

 

shortest-path tree rooted at vertex v is a spanning tree T of G, such that the path distance from root v to any other vertex u in T is the shortest path distance from v to u in G.

Path s a b c d parent
{ } -
{ s } - 2 7 s (parent of a)
{ s,a } - min(7,5) = 5 10 7 a (parent of b)
{ s,a,b } - - - min(10,6) = 6 7 b (parent of c)
{ s,a,b,c } - - - - min(7,8) = 7 a (parent of d)

So the graph has edges sa, ab, bc and ad

so sum = sa+ab+bc+ad = 2+3+1+5 = 11

answered by Boss (7.7k points)  
selected by


Top Users Mar 2017
  1. rude

    5118 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2730 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1422 Points

  8. Akriti sood

    1382 Points

  9. Bikram

    1350 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,531 questions
26,861 answers
61,190 comments
23,206 users