Consider the following statements about Bellman ford algorithm for finding shortest path in a directed connected graph G having integral edge weights.
Statement I: It will always find out negative edge weight cycle in G reachable from source.
Statement II: It will always give correct answer for the graph G.
Choose from the options given below.
(A) Both statements are true
(B) Both statements are false
(C) Statement I is true and Statement II is false
(D) Statement II is true and Statement I is false
Explanation: Statement 1 is true as in the nth iteration of Bellman Ford, if the length of the path of any node reachable from the source is decreased, that means we are having negative edge weight cycle in the graph.
Statement 2 is false as no algorithm can give give correct answer if the Graph is having negative edge weight cycle.
Quiz of this Question
Attention reader! Don’t stop learning now. Learn all GATE CS concepts with Free Live Classes on our youtube channel.