Learning Rooms/□ Level 4 · Systems Engineer/Computing and algorithms
Dijkstra's Algorithm - Computerphile
Computerphile · Length: see YouTube · captions on YouTube · nothing loads until you press play
By the end you can…
- Extend BFS to Dijkstra's algorithm using a priority queue (heapq) and per-cell costs.
- Compare BFS and Dijkstra on the same maps by path length, path cost and cells expanded.
- Structure the planner as modules with a map class and tests with known answers.
Watch it all: no segment has been checked by hand for this video yet.
1.Predict before you press play
A straight route crosses 3 rough cells (cost 9 each) then 1 floor cell; a detour has 6 floor cells (cost 1 each). Which does Dijkstra choose?
Pick one before you press play. A wrong guess is fine: it is what makes the video stick.
2.See the idea first
Play with this diagram for a minute. It gives you something to hang the video on.
Loading the interactive…
Can't use the diagram? Read a description instead
The planner shows the same map under BFS and Dijkstra. BFS finds the fewest moves and may cross the rough (cost 5) patch; Dijkstra finds the lowest total cost and may detour round it, expanding cells in order of cost so far. The readout reports moves, total cost and cells expanded for each.
3.Watch, actively
Works Dijkstra's shortest-path algorithm by hand on a small map, the improvement on breadth-first search in the term project.
Length: see YouTube · captions on YouTube · source
Nothing loads from YouTube until you press play.
Watch for…
- → Watch how the algorithm always picks the cheapest unfinished node next, and why that guarantees the cheapest route.
Pause whenever you like. Rewatching a hard minute is a good habit, not a failure.
Can't stream it? Read the idea instead
Dijkstra's algorithm finds the cheapest route through a network by always finishing the unfinished node with the lowest known cost next. Because costs are never negative, once a node is finished no cheaper route to it can turn up later.
What the video covers (our own note, written when we verified it): Works Dijkstra's shortest-path algorithm by hand on a small map, the improvement on breadth-first search in the term project.
Written by Tactiverge in our own words, not a transcript. The full lesson below explains the idea without the video.
Jot down one thing that surprised you and one question you still have.
4.Practise what you just saw
These come from the lesson that use this video and are checked on the server. Wrong answers get a hint and another try.
Practice 1
On a map where every free cell costs 1, how do BFS and Dijkstra compare?
Practice 2 · a fresh version every time
An editor keeps an undo stack of waypoint ids: s = []; s.append(38); s.append(23); s.append(27); s.pop(); s.append(33); s.pop(); s.append(3); s.pop(). What value does the final s.pop() return?
Practice 3
Why must Dijkstra's step costs be non-negative?
Practice 4
A path enters cells with costs 1, 1, 5, 5, 1, 1 (the start cell is free). What is its total cost?
5.Try it yourself
No simulation models this idea yet. The lesson below has an interactive diagram instead.
6.Build something with it
Follow-up project
Term project, part 1. Build the planner package (grid.py, planners.py, tests). Both planners must take a GridMap and return (path, cost, expanded). Tests must include a corridor, a forced detour, an unreachable goal, and a map where Dijkstra's path is longer but cheaper than BFS's, each with an answer worked by hand.
Where this video lives
- Project: plan a path that counts the cost · Level 3, week 9
In the course catalogue: CSE-320 Algorithms and numerical computation
The video is by Computerphile, embedded from YouTube with privacy-enhanced mode and never autoplayed. The room around it (prompts, notes, practice, projects) is Tactiverge's, written with AI assistance and checked by automated tests only.