All algorithms

Grid DFS (recursive)

DFS on a 2D grid — explores as far as possible along one direction before backtracking. Great for maze generation, connected-component labelling, and 'can I reach X?' checks.

time O(rows × cols)
space O(rows × cols) recursion

Press Tab out of the box or click Resetto regenerate frames from the current input.

Visualization
No frames yet — edit input and click Run.
Pseudocode
dfs(r, c):
  if out of bounds or wall or visited: return
  visited[r][c] = true
  for (dr, dc) in 4-neighbours:
    dfs(r + dr, c + dc)