Skip to content

DFS [mp]

Micro pattern

Description

Explore one branch fully before returning to another branch.

Problems

Graph components

Visit every reachable vertex before starting another component.

Trees

Process child subtrees recursively or with an explicit stack.

Grids

Treat valid neighboring cells as vertices and explore connected regions.