Trees & BST problems, grouped by pattern

Trees are recursion with structure. Traversals come first, then postorder with multiple return values, LCA, views, serialization and the BST property. Most tree problems reduce to deciding what each call returns to its parent.

When to reach for it

  • The input is a root node
  • You need a value per level, per path or per subtree
  • The tree is a BST and order matters

Mistakes to watch for

  • Validating a BST using only the parent value
  • Mixing up what a node returns vs what it records globally
  • Forgetting null children in serialization

The 43 problems

2Backtracking

4Views

5BST Basics

6Postorder + Multiple Return Values

8Child + Ancestor Handling

9Reverse Inorder Traversal

11Tree to Lists and vice-versa

12Miscellaneous BST Questions