This lesson's interactive features are locked, please to keep using them
Dijkstra's algorithm is an example of a greedy algorithm. Greedy algorithms make short-sighted optimization choices, so they're good at finding local maxima. If the local maximum isn't also the global maximum, then greedy algorithms can result in sub-optimal solutions.
When it comes to the kind of graph traversal we've been doing, the local maximum is guaranteed to be the global maximum, so Dijkstra's always finds the shortest path.
Greedy algorithms are bad when the solution space has many local maxima:
Greedy algorithms are great when the local maximum is the global maximum:
