Graphs
Shortest Path Algorithms
1. BFS: When All Edges Are Equal
How BFS Finds Shortest Paths
Walkthrough
Complexity
When to Use BFS
Problems That Use BFS for Shortest Path
2. Dijkstra's Algorithm: Non-Negative Weights
How Dijkstra Works
Walkthrough
Why It Works
Complexity
When to Use Dijkstra
Classic Dijkstra Problems
3. Bellman-Ford: When Negative Weights Exist
How Bellman-Ford Works
Why V-1 Iterations?
Walkthrough
Complexity
When to Use Bellman-Ford
4. Floyd-Warshall: All Pairs Shortest Path
How Floyd-Warshall Works
Walkthrough
Complexity
When to Use Floyd-Warshall
Classic Floyd-Warshall Problem
Quick Reference
Algorithm Selection
Complexity Comparison
Key Takeaways
Practice Problems
Purchase Premium to Keep Reading
Unlock this article and so much more with Hello Interview Premium
Unlock Premium Coding Content
On This Page
1. BFS: When All Edges Are Equal
How BFS Finds Shortest Paths
Walkthrough
Complexity
When to Use BFS
Problems That Use BFS for Shortest Path
2. Dijkstra's Algorithm: Non-Negative Weights
How Dijkstra Works
Walkthrough
Why It Works
Complexity
When to Use Dijkstra
Classic Dijkstra Problems
3. Bellman-Ford: When Negative Weights Exist
How Bellman-Ford Works
Why V-1 Iterations?
Walkthrough
Complexity
When to Use Bellman-Ford
4. Floyd-Warshall: All Pairs Shortest Path
How Floyd-Warshall Works
Walkthrough
Complexity
When to Use Floyd-Warshall
Classic Floyd-Warshall Problem
Quick Reference
Algorithm Selection
Complexity Comparison
Key Takeaways
Practice Problems