CS FundamentalsVery hardProduct company interview · GATE level

Dijkstra's algorithm is run from S on an undirected network with link costs S-A 7, S-B 2, S-C 6, A-B 3, B-D 8, A-D 4, B-C 5, C-E 5, D-E 1, D-F 6 and E-F 9. In what order are the nodes finalised, and what successive tentative labels does node E receive?

  1. A. S, B, A, C, D, E, F; E is labelled 10 only
  2. B. S, B, A, C, D, E, F; E is labelled 11, then 10
  3. C. S, B, C, A, D, E, F; E is labelled 11, then 10
  4. D. S, B, A, D, C, E, F; E is labelled 10 only

Correct answer: B. S, B, A, C, D, E, F; E is labelled 11, then 10

From S: A = 7, B = 2, C = 6. Finalise B (2): A improves to 5, D = 10, C stays 6 (2 + 5 = 7 is worse). Finalise A (5): D improves to 9. Finalise C (6): E = 11. Finalise D (9): E improves to 10, F = 15. Finalise E (10): F stays 15 (10 + 9 = 19). Finalise F (15). C (6) is finalised before D (9), so E is first labelled 11 through C and only later lowered to 10 through D. A (5) leaves the queue before C (6) because of the relaxation through B.

More Computer Networks questions

Exams that ask this topic