GATE / CS ARCHIVE

SIMILAR QUESTIONS / ALGORITHMS

Trace tentative distances and settled predecessors

5 questions solved the same way, newest first. Back to Algorithms

How these are solved

Given a small directed weighted graph and source, repeatedly settle the minimum tentative vertex and relax outgoing edges. Outputs differ: settlement order, actual shortest path or path cost.

2 marks · MCQ
Report issue

Dijkstra path under strict improvements

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

2 marks · MCQ
Report issue

Dijkstra finalization sequence

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

Descriptive
Report issue

Run Dijkstra's algorithm

Graph Algorithms

Question 17(a), GATE 1996: In the GFG p9 directed graph, edges with weights are A→B:6, A→C:90, A→F:2, A→E:70, B→D:41, C→B:12, C→E:10, D→C:12, F→B:22, F→C:60, F→D:50, E→F:15. GateForum p15 swaps the names E and F while keeping these positions and weights. Start at A. Give the Dijkstra settlement order.
Question 17(a), GATE 1996: In the GFG p9 directed graph, edges with weights are A→B:6, A→C:90, A→F:2, A→E:70, B→D:41, C→B:12, C→E:10, D→C:12, F→B:22, F→C:60, F→D:50, E→F:15. GateForum p15 swaps the names E and F while keeping these positions and weights. Start at A. Give the Dijkstra settlement order.
Tap to enlarge
Answer & solution

Answer: A, F, B, D, C, E (no official key was published)

Use the the paper labels first. Initialize d(A)=0 and all other labels to infinity. Settle A: tentative B=6,C=90,F=2,E=70. Settle F (2): B via F would be 24 and does not improve 6; C improves to 62 and D becomes 52. Settle B (6): D improves to 6+41=47. Settle D (47): C improves to 47+12=59. Settle C (59): E improves to 59+10=69; the edge back to B gives 71 and changes nothing. Finally settle E (69), whose edge to F gives 84 and changes nothing.

Thus the settlement order is A,F,B,D,C,E, with final distances 0,2,6,47,59,69 in that order. Predecessors for the E path are E←C←D←B←A, giving A→B→D→C→E and cost 6+41+12+10=69. This improves on the direct A→E cost 70 and the route A→F→C→E cost 72. All weights are nonnegative, so Dijkstra's settled distances are final.

A material the paper difference changes the answer to the named destination. Applying that relabelling, its settlement order is A,E,B,D,C,F. Its shortest A→E path is the direct edge of weight 2; the 69-cost bottom-vertex path ends at F there. The answers must remain tied to the chosen diagram. Decimal labels 90,60,50,70,10 contain zero glyphs, not an added symbolic variable.

Original paper, page 9

Descriptive
Report issue

Recover the shortest path

Graph Algorithms

Question 17(b), GATE 1996: In the GFG p9 directed graph, edges with weights are A→B:6, A→C:90, A→F:2, A→E:70, B→D:41, C→B:12, C→E:10, D→C:12, F→B:22, F→C:60, F→D:50, E→F:15. GateForum p15 swaps the names E and F while keeping these positions and weights. Start at A. Give the shortest A→E vertex sequence.
Question 17(b), GATE 1996: In the GFG p9 directed graph, edges with weights are A→B:6, A→C:90, A→F:2, A→E:70, B→D:41, C→B:12, C→E:10, D→C:12, F→B:22, F→C:60, F→D:50, E→F:15. GateForum p15 swaps the names E and F while keeping these positions and weights. Start at A. Give the shortest A→E vertex sequence.
Tap to enlarge
Answer & solution

Answer: A, B, D, C, E (no official key was published)

Use the the paper labels first. Initialize d(A)=0 and all other labels to infinity. Settle A: tentative B=6,C=90,F=2,E=70. Settle F (2): B via F would be 24 and does not improve 6; C improves to 62 and D becomes 52. Settle B (6): D improves to 6+41=47. Settle D (47): C improves to 47+12=59. Settle C (59): E improves to 59+10=69; the edge back to B gives 71 and changes nothing. Finally settle E (69), whose edge to F gives 84 and changes nothing.

Thus the settlement order is A,F,B,D,C,E, with final distances 0,2,6,47,59,69 in that order. Predecessors for the E path are E←C←D←B←A, giving A→B→D→C→E and cost 6+41+12+10=69. This improves on the direct A→E cost 70 and the route A→F→C→E cost 72. All weights are nonnegative, so Dijkstra's settled distances are final.

A material the paper difference changes the answer to the named destination. Applying that relabelling, its settlement order is A,E,B,D,C,F. Its shortest A→E path is the direct edge of weight 2; the 69-cost bottom-vertex path ends at F there. The answers must remain tied to the chosen diagram. Decimal labels 90,60,50,70,10 contain zero glyphs, not an added symbolic variable.

Original paper, page 9

Descriptive
Report issue

Compute the shortest-path cost

Graph Algorithms

Question 17(c), GATE 1996: In the GFG p9 directed graph, edges with weights are A→B:6, A→C:90, A→F:2, A→E:70, B→D:41, C→B:12, C→E:10, D→C:12, F→B:22, F→C:60, F→D:50, E→F:15. GateForum p15 swaps the names E and F while keeping these positions and weights. Start at A. Give the shortest A→E cost.
Question 17(c), GATE 1996: In the GFG p9 directed graph, edges with weights are A→B:6, A→C:90, A→F:2, A→E:70, B→D:41, C→B:12, C→E:10, D→C:12, F→B:22, F→C:60, F→D:50, E→F:15. GateForum p15 swaps the names E and F while keeping these positions and weights. Start at A. Give the shortest A→E cost.
Tap to enlarge
Answer & solution

Answer: 69 (no official key was published)

Use the the paper labels first. Initialize d(A)=0 and all other labels to infinity. Settle A: tentative B=6,C=90,F=2,E=70. Settle F (2): B via F would be 24 and does not improve 6; C improves to 62 and D becomes 52. Settle B (6): D improves to 6+41=47. Settle D (47): C improves to 47+12=59. Settle C (59): E improves to 59+10=69; the edge back to B gives 71 and changes nothing. Finally settle E (69), whose edge to F gives 84 and changes nothing.

Thus the settlement order is A,F,B,D,C,E, with final distances 0,2,6,47,59,69 in that order. Predecessors for the E path are E←C←D←B←A, giving A→B→D→C→E and cost 6+41+12+10=69. This improves on the direct A→E cost 70 and the route A→F→C→E cost 72. All weights are nonnegative, so Dijkstra's settled distances are final.

A material the paper difference changes the answer to the named destination. Applying that relabelling, its settlement order is A,E,B,D,C,F. Its shortest A→E path is the direct edge of weight 2; the 69-cost bottom-vertex path ends at F there. The answers must remain tied to the chosen diagram. Decimal labels 90,60,50,70,10 contain zero glyphs, not an added symbolic variable.

Original paper, page 9