Data Structures & AlgorithmsHardProduct-company MCQ pattern

Bellman–Ford from A relaxes the directed edges in the fixed order C→D (2), B→C (3), A→B (4), A→C (9), B→D (7). After the FIRST full pass, what are the distance estimates of C and D?

  1. A. C = 9, D = ∞
  2. B. C = 9, D = 11
  3. C. C = 7, D = 9
  4. D. C = 7, D = 11

Correct answer: B. C = 9, D = 11

In pass 1, C→D and B→C do nothing (C and B are still ∞); A→B sets B = 4; A→C sets C = 9; B→D sets D = 4 + 7 = 11. The final values C = 7 (via B) and D = 9 appear only after pass 2, which is why V − 1 passes are needed.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic