TweakCode
Recursion lessons

Course 03 · Orientation

Recursion

The gate

Functions that call themselves on a smaller input, then the structures defined that way: binary trees, search trees, heaps, and tries.

Start with Recursion

The course journey

Build one family of skills at a time

Each technique is three short lessons, and each one builds on the lesson before it. A lesson walks through one problem step by step, then hands it to you along with a few more to solve on your own.

  1. 01Start here

    Recursion

    Trust a smaller call down to a base case, split work in halves, then cache repeated calls by their arguments.

    1. Stage 1Call Stack & Base CasesBreak a problem into a smaller self-call plus a stopping condition1 Lesson · 3 Problems
    2. Stage 2Divide & Conquer SplitsSplit the input in half, solve both sides, and combine the results1 Lesson · 3 Problems
    3. Stage 3Memoized Recursion (Top-Down)Cache repeated subproblem results by argument key1 Lesson · 3 Problems
  2. 02Pro

    Trees

    A node, a left child, a right child. The recursion is the traversal.

    1. Stage 1

      Depth-First Tree Traversal

    2. Stage 2

      Bottom-Up Recursion

    3. Stage 3

      Level-Order BFS

    Preview
  3. 03Pro

    BST

    Left subtree smaller, right subtree larger: prune a search to one path, read values in order, and pass bounds down to check the rule.

    1. Stage 1

      BST Search & Pruning

    2. Stage 2

      In-Order Sorted Traversal

    3. Stage 3

      Range Bounds & BST Validation

    Preview
  4. 04Pro

    Heap

    A complete tree in an array. The smallest item is always on top.

    1. Stage 1

      Heap-Backed Priority Queue

    2. Stage 2

      Top-K Elements

    3. Stage 3

      K-Way Merge

    Preview
  5. 05Pro

    Tries

    A tree of prefixes: walk one character edge per level, branch on wildcards, and steer grid or stream searches with it.

    1. Stage 1

      Prefix Tree Insertion & Lookup

    2. Stage 2

      Wildcard & Backtracking on Tries

    3. Stage 3

      Multi-Word Grid & Stream Pruning

    Preview