Depth First Search on Graphs

Prereq: Graph Intro

We build on DFS on trees.

Similar to BFS, we just have to add visited to keep track of the visited nodes and use get_neighbors to get the next nodes to visit.

Here's a visualization of the recursive call stack during DFS on a graph:

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro