Skip to content
core-pattern

Tree Depth-First Search

Use DFS to propagate subtree results, path state, and structural information through trees.

Problems

Problems in Tree Depth-First Search

Practice problems that share this primary solution pattern and compare the clues that reveal it.

Smartphone displaying AI app with book on AI technology in background.
beginner
10 min read

Binary Tree Inorder Traversal

The difficult part of inorder traversal is not remembering “left, node, right.” It is preserving the parent node while the left subtree is still…

View solution
Detailed view of a sewing machine needle stitching fabric, highlighting sewing process and textile technology.
advanced
12 min read

Recover Binary Search Tree

A binary search tree has a structural invariant that is more useful than its parent-child relationships: inorder traversal visits values in sorted order.…

View solution
Bright geometric pattern on a fence with green and white circles against a blue sky.
beginner
10 min read

Same Tree

A tree comparison fails the moment you forget that a missing child is also part of the structure.

View solution