Under what circumstances would you prefer using Bellman-Ford algorithm over Dijkstra's or Floyd-Warshall algorithms?

  • When the graph has no negative edge weights.
  • When the graph is connected by only one path.
  • When the graph is dense and has positive edge weights.
  • When the graph is sparse and has negative edge weights.
The Bellman-Ford algorithm is preferred when the graph is sparse and contains negative edge weights. Unlike Dijkstra's algorithm, Bellman-Ford can handle graphs with negative weights, making it suitable for scenarios where negative weights are present.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *