...
GATE 2009
October 15, 2023
GATE 2009
October 15, 2023
GATE 2009
October 15, 2023
GATE 2009
October 15, 2023

Algorithms

Question 198

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 198 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.
More Info: The Dijkstra’a algorithm:
–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
Correct Answer: B
Question 198 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.
More Info: The Dijkstra’a algorithm:
–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
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!