What's Next?
Congratulations
You have implemented 12 tree algorithms in C: node creation, all three traversals, node count, height, leaf count, sum, BST insert, BST search, min/max, and BST validation.
That is real data structures knowledge — the kind that comes up in every technical interview and underpins every database and compiler ever written.
What to Explore Next
You have covered the fundamentals. Here is where to go deeper:
- BST Delete — The hardest BST operation. When deleting a node with two children, replace it with its inorder successor (the smallest node in its right subtree).
- Balanced BSTs (AVL Trees) — A BST stays O(log n) only if it's balanced. AVL trees self-balance on insert and delete using rotations.
- Red-Black Trees — The self-balancing BST used by Linux's process scheduler, Java's
TreeMap, and C++'sstd::map. - B-Trees — N-ary trees optimized for disk access. The structure behind every database index.
- Tries — Trees for string prefixes. Used in autocomplete, spell checkers, and IP routing tables.
- Heaps — A tree with a different invariant (parent ≤ children). The structure behind priority queues.
Build Something
- A sorted set — use a BST to build a dynamic sorted container with insert, search, delete, and iteration.
- An expression evaluator — parse arithmetic expressions into a tree and evaluate them recursively.
- A file system simulator — implement a tree of directories and files with path traversal.
- A spell checker — build a trie from a dictionary and check words character by character.
References
- Introduction to Algorithms (CLRS) by Cormen, Leiserson, Rivest, and Stein — Chapter 12 covers BSTs; Chapters 13-14 cover Red-Black Trees and augmented data structures.
- The Algorithm Design Manual by Steven Skiena — practical discussion of tree variants and when to use each.
- Visualgo - BST — animated visualization of BST insert, delete, and search.
- CS50x Data Structures — Harvard's free course covers trees with excellent C examples.