Why is Dijkstra's Algorithm Greedy?
At every step, Dijkstra's algorithm picks the closest unvisited node and commits to it - it never revisits that choice. This greedy strategy works because all edge weights are non-negative: once a node is settled with its minimum distance, no future relaxation could ever make it shorter.
Time & Space Complexity
- With Binary HeapO((V + E) log V)
- With Array (naive)O(V²)
- SpaceO(V + E)
Real-World Use Cases
- GPS navigation and route planning
- Network routing protocols (OSPF)
- Flight/transit connection search