Graphs

Concept shape

Practice pattern
Definition

Depth-first search explores one path deeply before backtracking.

Step 1 / 5
Concept shape
Current lesson

DFS Concept Lab

Graphs Practice pattern

DFS Concept

Welcome to the DFS Concept concept lab. Depth-first search explores one path deeply before backtracking. The must know points are: Can be recursive or stack-based. Useful for components and cycle checks. Backtracking is DFS with choices. The common operations are: visit, recurse, backtrack. The complexity shape is O(V + E). Watch out for these pitfalls: Stack overflow on deep graphs. Forgetting visited state. Related algorithms include DFS, Backtracking.

Concept details

Depth-first search explores one path deeply before backtracking.

Must know

  • Can be recursive or stack-based.
  • Useful for components and cycle checks.
  • Backtracking is DFS with choices.
1.0x