Store things and their connections, then explore them: nearest first, or along one path to its end.
Stacks and queues: a queue gives back its oldest entry, and a stack gives back its newest
Recursion: each function call goes on the call stack, and it comes off when the call returns
Hash sets: a fast way to check whether you have already seen something
Lesson 1 · Things and connections
Next: 13 · Weighted graphs: Dijkstra and topological order · 8 lessons · 1 h 39 min
Try the same model with your own values. No checks, nothing recorded.
Open the playground