← All sections

Trees

A deep dive into recursion; the gateway to heap and graph.

0/7 lessons · exam: 0/30%

Lessons

  1. ✓01

    Recognizing tree problems

    The TreeNode node, recursion as the natural tool, traversals, and the O(n)/O(h) complexity.

  2. ✓02

    Pattern 1: Recursive DFS

    The recursive template that solves most trees: solve the children, then combine.

  3. ✓03

    Pattern 2: Level-order BFS

    When the question is per level, breadth-first search with a queue processes layer by layer.

  4. ✓04

    Pattern 3: Binary search tree (BST)

    The left < node < right property, which gives O(h) search and sorted order via the in-order traversal.

  5. ✓05

    Pattern 4: Construction and serialization

    Rebuilding a tree from traversals and serializing it without ambiguity.

  6. ✓06

    Pattern 5: Trie (prefix tree)

    The character tree that makes prefix and word search highly efficient.

  7. ✓07

    Synthesis: which pattern to use?

    The Trees section's decision tree and the general quiz before the final exam.

🏁 FINAL EXAM

1 easy + 1 medium + 1 hard — unseen problems

With hidden test cases, just like the real LeetCode. This is where you confirm you can leave the section solving any problem of the topic.