October 15, 2023
October 15, 2023
October 15, 2023
###### GATE 2009
October 15, 2023
 Question 13

Which of the following statement(s) is/are correct regarding Bellman-Ford shortest path algorithm?

P. Always finds a negative weighted cycle, if one
Q. Finds whether any negative weighted cycle is reachable from the source.
 A P Only B Q Only C Both P and Q D Neither P nor Q
Question 13 Explanation:
Bellman-Ford shortest path algorithm is a single source shortest path algorithm. So it can only find cycles which are reachable from a given source, not any negative weight cycle. Consider a disconnected where a negative weight cycle is not reachable from the source at all. If there is a negative weight cycle, then it will appear in shortest path as the negative weight cycle will always form a shorter path when iterated through the cycle again and again.
–A greedy algorithm
–Works when weights are all non-negative
The bellman ford algorithm: If there is a negative cycle, there is no solution, but negative weight edges are allowed.

– Add this cycle again can always produces a less weight path
—If there is no negative cycle, a shortest path has at most |V|-1 edges
—A dynamic programming algorithm
Note: Dijkastra is faster than Bellman-Ford
Question 13 Explanation:
Bellman-Ford shortest path algorithm is a single source shortest path algorithm. So it can only find cycles which are reachable from a given source, not any negative weight cycle. Consider a disconnected where a negative weight cycle is not reachable from the source at all. If there is a negative weight cycle, then it will appear in shortest path as the negative weight cycle will always form a shorter path when iterated through the cycle again and again.
–A greedy algorithm
–Works when weights are all non-negative
The bellman ford algorithm: If there is a negative cycle, there is no solution, but negative weight edges are allowed.

– Add this cycle again can always produces a less weight path
—If there is no negative cycle, a shortest path has at most |V|-1 edges
—A dynamic programming algorithm
Note: Dijkastra is faster than Bellman-Ford