101 Logo
onenoughtone

Interactive DFS Visualization

Graph Traversal

Watch how DFS traverses a graph, exploring as far as possible along each branch before backtracking.

Interactive Visualization:

DFS Graph Traversal Visualization (Recursive)
Unvisited
In Stack
Visiting
Visited
Recursion Stack:
Stack is empty

Edge Types:

Unvisited
Discovery
Back
Cross
Forward

Step 0 of 44: Initial state

Maze Solving

See how DFS can be used to solve a maze by exploring one path at a time until the exit is found.

Interactive Visualization:

DFS Maze Solving Visualization
Start
End
Wall
Visited
Path
S
E
DFS Stack:
Stack is empty

How DFS Solves Mazes: DFS explores one path as far as possible before backtracking. It uses a stack to keep track of positions to visit. When it reaches a dead end, it backtracks to the last position with unexplored paths. This continues until it finds the exit or exhausts all possibilities.

Step 0 of 59: Initial state

Cycle Detection

Explore how DFS can detect cycles in a graph by keeping track of vertices in the current recursion stack.

Interactive Visualization:

DFS Cycle Detection Visualization
Unvisited
In Stack
Visiting
Visited
In Cycle
Recursion Stack:
Stack is empty

How DFS Detects Cycles: DFS keeps track of nodes in the current recursion stack. If we encounter a node that is already in the recursion stack, we've found a cycle. This is because there's a path from that node back to itself, which is the definition of a cycle.

Step 0 of 21: Initial state

IntroVisualizePatternsPractice
101 Logo
onenoughtone