Question discussion

Which of the following shortest-path algorithms can handle graphs that contain negative edge weights (but no negative cycles)?

1784Medium DSSSB TGT Computer Science 0 replies

Which of the following shortest-path algorithms can handle graphs that contain negative edge weights (but no negative cycles)?

  • ABellman–Ford algorithm
  • BDijkstra's algorithm
  • CPrim's algorithm
  • DKruskal's algorithm
Correct answer: A

Explanation

Bellman–Ford relaxes every edge V − 1 times and works with negative weights, whereas Dijkstra's algorithm assumes non-negative weights.

Discussion 0

Nobody has replied yet. Start the discussion!