edited by
711 views
3 votes
3 votes

Answer is given as (B). But, shouldn't it relax point 'c' via 'a' .. So, i guess answer should be D. Is it?

edited by

4 Answers

2 votes
2 votes

ans is D) a-c-f-g

vertex  parent

a            NULL

b           a

c           a

d          b

e          c

f          c

g         f

0 votes
0 votes
B should be answer as source is given as a  and as Dijkastra algorithm we will pick b
–2 votes
–2 votes

Dijikstra's algorithm should have traverse minimum weight of path. So we can derive like below from above graph through given optional,

(a){a,d,c,f,g} ={6(initial weight) + 2 + 3 + 1} = 12

(b){a,b,d,c,f,g} = {3(initial weight) + 2 + 2 + 3 + 1} = 11

(c){a,c,g} = {5(initial weight) + 7} = 12

(d){a,c,f,g} = {5(initial weight) + 3 + 1} =9

 So answer is B.

Note:  if same weight available in a graph ,at that time we shall take minimum value of initial node will take as followed by next node to destination.

edited by

Related questions

2 votes
2 votes
0 answers
4