What is the time complexity of the Bellman-Ford algorithm?
Show answer
O(V * E)
Bellman-Ford is used for single-source shortest paths and is more versatile than Dijkstra because it can handle negative weight edges. It also detects negative cycles, which would otherwise make the shortest path undefined.
Also asked as:
- What is the Big O time complexity of the Bellman-Ford algorithm in terms of vertices (V) and edges (E)?