| Quick Reference Trees CheatsheetA tree on one page — roots, walks, and the traps around height, a skewed BST, and heap indexes. 10 sections 10 tables 14 code snippets Root, leaves, and edgesLeft and right Stop on a missing node The parts
This page is a tree. A graph is left out. Full, complete, perfectA level doubles Three names people mix up
Four walksNode, then left, then right Left, then node, then right Where each order is used
Binary search treeSmaller goes left The order is on every descendant
Delete a BST nodeTwo children keep both subtrees Three shapes
Level by levelFreeze this level before children join A queue, one depth at a time
A heap is not a BST0-based child slots Complete tree, stored in a list
Keeping the height lowLeft height minus right height AVL and red-black
Time and stack spaceEmpty is -1, so a leaf is 0 Balance changes the cost
Interview trapsSorted only for a BST A stack dives A missing node has no child Traps worth memorising
How to use this page: count edges for height, trust inorder for sorted output only on a BST, and use a queue for one level. |