Pattern Recognition Drill
Easy Graphs
The Problem
Traverse a graph depth-first using recursion.
What approach would you use?
Think about it before scrolling down.
Visit node, mark visited, recurse on unvisited neighbors. O(V+E).
Iterative DFS with explicit stack — avoids stack overflow on very deep graphs.
Common Trap
Python's recursion limit (default 1000) can be hit on large graphs. sys.setrecursionlimit or use iterative.