GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 40

Dijkstra path under strict improvements

Algorithms · Graph Algorithms · Full GATE CSE 2012 paper

GATE 2012, Q40 2 marks · MCQ
Report issue

Graph Algorithms

Question 40, GATE 2012: Run Dijkstra from S to T on the directed weighted graph below. Update a vertex’s path only when a strictly shorter path is found, never on an equal-distance tie. Which path is reported? The complete directed edge list (source,target,weight) is: (S,A,4), (S,B,3), (B,S,3), (S,D,7), (A,C,1), (B,D,4), (C,D,3), (C,E,1), (D,E,1), (D,F,5), (D,T,3), (E,G,2), (G,E,2), (E,T,4), (G,T,3), (T,F,5).
(A) SDT (B) SBDT (C) SACDT (D) SACET.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (27 steps)

After settling S, tentative distances are B=3, A=4 and D=7. Settling B offers D=3+4=7, an equal value that does not replace predecessor S. Settling A discovers C=5. Settling C discovers E=6; its edge to D offers 8 and is ignored. E is settled before D and gives T=6+4=10 with predecessor E (and G=8). D then offers T=7+3=10, which is equal and therefore cannot replace the predecessor. The path retained is S→A→C→E→T of length 10, option D. The graph’s G→E edge and T→F edge directions must not be reversed.

Check: The decisive relaxation is E→T, performed at distance 6 before D is settled at distance 7. Both propose distance 10, but only the first establishes T’s predecessor. Thus equal shortest lengths do not imply that a later equal path replaces the already stored path.

Original paper, page 10 · Answer key