Medium Algorithms Graph Algorithms
When would you use Bellman-Ford over Dijkstra's algorithm?
Answer
Bellman-Ford handles negative edge weights (Dijkstra cannot) and detects negative cycles. It relaxes all edges V-1 times; if any edge can still be relaxed, negative cycle exists. Time complexity is O(VE), slower than Dijkstra's O((V+E)log V). Use Bellman-Ford when: graph has negative weights (currency arbitrage), need to detect negative cycles, or graph is dense and simple implementation is preferred.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Software Engineer Algorithm Developer Backend Developer