Start Learning
Javaneer
Back to roadmap
🌳
Stage 4

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.

5 Lessons in this stage1 h 13 min
Start the first lesson

Lessons in this stage

  1. 01

    Tree Traversals

    Intermediate

    Preorder, 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
  2. 02

    Thinking Recursively on Trees

    Intermediate

    The template behind most tree problems: solve for the children, then combine - depth, node counts, and 'is this balanced?' all follow one shape.

    15 min
  3. 03

    Binary Search Trees

    Intermediate

    The BST invariant (left < node < right) gives O(log n) search, insert, and delete - and why an inorder traversal comes out sorted.

    15 min
  4. 04

    Lowest Common Ancestor

    Advanced

    A 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
  5. 05

    Balance, Heaps & Tries

    Advanced

    Why 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