

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to DS&A 2
incomplete
2: Dijkstra's Algorithm
incomplete
3: Dijkstra's: Get Path
incomplete
4: Weighted Graphs
incomplete
5: Next Nearest Node
incomplete
6: Dijkstra's Algorithm
incomplete
7: Dijkstra's Algorithm Review
incomplete
8: Dijkstra's Time Complexity
incomplete
9: Greedy Algorithms
incomplete
10: Dijkstra's vs. DFS
incomplete
Back
ctrl+,
Next
ctrl+.
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: