Shortest Paths
Cheapest routes through weighted graphs — Dijkstra, 0-1 BFS, Bellman-Ford, and Floyd-Warshall.
This topic is part of Pro.
Free covers the C and Python courses, the first three DSA topics, the opening system design lessons and the beginner AI lessons, all with the full coach. Pro opens the rest of the library in the FollowtheDamnCode app.
What is in it
- 1Dijkstra's algorithmAlways settle the closest unsettled vertex, using a min-heap — the standard for non-negative weights. Pro
- 20-1 BFSWhen edges cost only 0 or 1, a deque replaces the heap — free edges to the front, paid edges to the back. Pro
- 3Bellman-FordRelax every edge V − 1 times — handles negative weights, detects negative cycles, and limits path length. Pro
- 4All pairs, and choosing an algorithmFloyd-Warshall's three loops for every pair, shortest paths in a DAG, and a decision table. Pro