GATE / CS ARCHIVE

GATE CSE 2009 / QUESTION 13

Bellman-Ford negative-cycle scope

Algorithms · Graph Algorithms · Full GATE CSE 2009 paper

GATE 2009, Q13 1 mark · MCQ
Report issue

Graph Algorithms

Question 13, GATE 2009: For single-source Bellman–Ford, assess P: always detects a negative cycle if any exists; Q: detects whether a negative cycle is reachable from the source. A P only; B Q only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Single-source Bellman-Ford detects a negative cycle reachable from that source by checking for a further relaxable edge after n−1 passes. A negative cycle in an unreachable component remains at infinite distance and need not be found. Therefore Q is true but P is not, giving B.

Bellman–Ford initializes only the source distance as finite. Vertices unreachable from it remain at infinity, so a disconnected negative cycle does not cause a finite relaxation. After |V|−1 passes, an additional successful relaxation among reachable vertices detects a reachable negative cycle. Therefore Q is true and P, which omits reachability, is false. Connecting a new super-source to every vertex would change the setup and allow global detection.

Original paper, page 3