Data Structures & AlgorithmsHardICPC regional · shortest path

Problem: Which statement about the Bellman-Ford algorithm is correct when there is a negative cycle reachable from the source?

  1. A. The algorithm returns the correct distances
  2. B. The algorithm is undefined and crashes
  3. C. A further relaxation after V - 1 passes still succeeds
  4. D. The distances are all zero

Correct answer: C. A further relaxation after V - 1 passes still succeeds

After V - 1 passes a reachable negative cycle always allows one more improvement, which is how it is detected.

More Coding Interview Problems questions

Exams that ask this topic