GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 44

Dijkstra finalization sequence

Algorithms · Graph Algorithms · Full GATE CSE 2004 paper

GATE 2004, Q44 2 marks · MCQ
Report issue

Graph Algorithms

Question 44, GATE 2004: Run Dijkstra from P on the directed graph with vertices P,Q,R,S,T,U and weighted arcs P→Q:1, P→S:6, P→T:7, Q→R:1, Q→S:4, R→S:2, R→U:1, S→T:3, S→U:2, T→U:2. In what order are shortest-path distances finalized? This arc list completely specifies the source figure.
Options:
(A) P,Q,R,S,T,U
(B) P,Q,R,U,S,T
(C) P,Q,R,U,T,S
(D) P,Q,T,R,U,S
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (18 steps)

1. From P, tentative distances are Q=1,S=6,T=7. Finalizing Q sets R=2 and improves S=5.

2. Finalizing R sets U=3 and improves S=4. U has no outgoing improvement, so S=4 is next; S gives T=min(7,4+3)=7.

3. The order is P,Q,R,U,S,T, with final distances 0,1,2,3,4,7 in that order. In particular the diagonal edge is directed R→S, not S→R.

4. Teaching check: Record the finalized distances in extraction order: P:0,Q:1,R:2,U:3,S:4,T:7. Once R is processed, its outgoing R→S edge lowers S to 4. Reversing that arrow would alter the computation, so direction is part of the essential figure data.

Original paper, page 6