The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+2 votes
105 views

asked in Algorithms by Active (1.4k points) | 105 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 (8.7k points)
selected by


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

29,154 questions
36,976 answers
92,138 comments
34,816 users