Trees & BSTs
Recursion's natural home.
Trees turn recursion from a trick into a way of thinking. Master the traversals (preorder, inorder, postorder, level-order), the binary-search-tree invariant, and the recursive patterns that solve depth, balance, and lowest-common-ancestor problems.
Lessons in this stage
- 01
Tree Traversals
IntermediatePreorder, inorder, and postorder DFS, plus level-order BFS - the four ways to visit every node, and when each one is the right tool.
16 min - 02
Thinking Recursively on Trees
IntermediateThe template behind most tree problems: solve for the children, then combine - depth, node counts, and 'is this balanced?' all follow one shape.
15 min - 03
Binary Search Trees
IntermediateThe BST invariant (left < node < right) gives O(log n) search, insert, and delete - and why an inorder traversal comes out sorted.
15 min - 04
Lowest Common Ancestor
AdvancedA favorite interview problem: find the deepest node that is an ancestor of two others, in a plain binary tree and in a BST.
13 min - 05
Balance, Heaps & Tries
AdvancedWhy balance matters (and what a self-balancing tree buys you), how a heap is a tree in an array, and the trie for prefix problems.
14 min