SOARDO
Software Engineer (SDE)dsaadvanced3 interactive MCQs in app

Shortest Path: Dijkstra & Bellman-Ford

Dijkstra min-heap + stale entry guard on non-negative weightsBellman-Ford O(VE) for negative weightswhy negative edges break Dijkstra greedy settle

Dijkstra’s algorithm finds single-source shortest paths on **non-negative weighted** graphs in `O((V + E) log V)` using a min-heap `(dist, node)`. Always check stale heap entries: `if d > dist[u]: continue`! When weights can be **NEGATIVE** (no negative cycles), use Bellman-Ford relaxing all `E` edges `V - 1` times in `O(V * E)`.

from `A` with edges `A->B(4), A->C(1), C->B(2)`, Dijkstra pops `(1, C)` before `(4, B)` and relaxes `dist[B]` down to `1 + 2 = 3` cleanly!
running Dijkstra on negative edge weights (greedy pop assumes settled `dist[u]` can never drop later, which negative edges break!) or forgetting stale heap skip.
Dijkstra Shortest Path — GeeksforGeeksread ↗Shortest Path: Dijkstra & Bellman-Ford — Applied Practicepractice ↗VisuAlgo Interactive Visualizationsvisualize ↗NeetCode DSA Roadmappractice ↗

Practice Shortest Path: Dijkstra & Bellman-Ford with 3 graded MCQs & written feedback.

Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.

Test yourself free on SOARDO →View full Software Engineer roadmap

More Software Engineer Study Guides