In which scenario would you choose Dijkstra's algorithm over Bellman-Ford or Floyd-Warshall algorithms?

  • In scenarios where the graph has cycles.
  • When dealing with a graph with negative edge weights.
  • When the graph has both positive and negative edge weights.
  • When working with a graph with non-negative edge weights.
Dijkstra's algorithm is preferred over Bellman-Ford or Floyd-Warshall algorithms when working with a graph that has non-negative edge weights. Unlike Bellman-Ford, Dijkstra's algorithm does not handle negative weights and is more efficient in such scenarios.
Add your answer
Loading...

Leave a comment

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