Lessons
C++ · Graphs · 48. Depth-First Search

step 1 of 6

Go deep first

Depth-first search walks like a maze explorer: take the first road, keep going, and back up only when stuck.

dfs calls itself for each new neighbour. seen remembers where I've been.

Mission

Start the walk from node 3, then RUN.

PIP·1
main.cppyour code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
← press me!
readyscreen

Press RUN to see what this program does.

Do the mission and Next turns green.

Depth-First Search