Data structures › Weighted graphs: Dijkstra and topological order
Tutorial 13 of 13 · Data structures · Graphs · Beginner Weighted graphs: Dijkstra and topological order Find the cheapest route across a map, and a safe order for jobs that depend on each other.
8 lessons, the last is a challenge · about 1 h 30 min · Python and Java
Before you start Graphs: nodes, edges, adjacency lists and BFS (the graphs tutorial)
Heaps: push and pop on a min-heap (the heaps tutorial)
Watch first · about 8 min PlayDijkstra's algorithm: how a map finds the shortest route. The narration uses an AI clone of the creator’s voice. What you’ll be able to do 1 Say what weights and direction add to a graph, and why the path with the fewest edges is not always the shortest. 2 Follow Dijkstra's algorithm by hand: the heap, each edge relaxed, which node is finalised next, and which heap entries are out of date. 3 Rebuild a shortest path from its parents, and say when a parent is written. 4 Put jobs in a valid order by counting what each one waits for, and recognise a cycle from the nodes left over. 5 Choose between BFS, Dijkstra's algorithm and topological order for a problem, and name what Python and Java give you. Lessons Next path Next path: Interview practice · Intermediate · 4 tutorials · about 4 h 30 min
After the Data structures path: the problems here use hash maps, two pointers, binary search, linked lists and shortest paths, solved in Python or Java.
Playground Try the same model with your own values. No checks, nothing recorded.
Open the playground