GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Bellman–Ford is run from A on the directed graph A→B 4, A→C 2, C→B 1, B→D 5, C→D 8, D→E 3, C→E 10, E→F −2, D→F 6. In each pass the edges are relaxed in this fixed order: D→F, E→F, D→E, C→E, B→D, C→D, C→B, A→C, A→B. What is the label of F after exactly 3 passes?

  1. A. 9
  2. B. 10
  3. C. 14
  4. D. ∞

Correct answer: B. 10

Pass 1 fixes only B = 4 and C = 2 (the edges out of D and E come first). Pass 2 gives D = 9, E = 12, B = 3 but F is relaxed before D and E have values. In pass 3, F becomes 10 via E = 12, while E only drops to 11 later in that pass (after D = 8); F = 9 appears in pass 4.

More Algorithms questions

Exams that ask this topic