Data Structures & AlgorithmsHardICPC regional · algorithm theory

Problem: In Bellman-Ford, which statement about early termination is correct?

  1. A. The algorithm can stop after the first pass whenever a negative edge exists
  2. B. Early termination is impossible on graphs with negative weights
  3. C. It stops once the source has no outgoing edges
  4. D. If one full pass relaxes no edge, all distances are final and the algorithm can stop

Correct answer: D. If one full pass relaxes no edge, all distances are final and the algorithm can stop

No relaxation in a pass means every edge satisfies the shortest-path condition, so further passes cannot change anything.

More Coding Interview Problems questions

Exams that ask this topic