← Tree Recursion

Pattern Recognition Drill

#35 — BST search

Easy Trees

The Problem

Search for a value in a BST. Return the node or None.

What approach would you use?

Think about it before scrolling down.

Key Signals

Tree Recursion

Compare with root, recurse left or right. O(h) time — O(log n) for balanced, O(n) for skewed.

Common Trap

Iterative version is also fine and avoids stack overhead: while node: go left or right.

← #34 #36 →