09. Trees
🧠Tree Strategy
- Recursion is King: 90% of tree problems are solved by trusting the recursive call on
leftandright. - Traversals:
- Inorder (Left-Root-Right): Sorted order for BST.
- Preorder (Root-Left-Right): Good for cloning/serializing.
- Postorder (Left-Right-Root): Good for deleting or bottom-up calculation (height).
- BST Property: Max of Left Subtree < Root < Min of Right Subtree.
🟢 Traversals & Views
- Inorder Traversal
- Preorder Traversal
- Postorder Traversal
- Level Order
- ZigZag Level Order Traversal BT
- Vertical Order Traversal
- Right View Of Binary Tree
- Left View Of Binary Tree
- Top View Of Binary Tree
- Boundary Traversal Of Binary Tree
🟡 Construction & Properties
- Tree Height
- Nodes Count
- Identical Binary Trees
- Symmetric Binary Tree
- Invert The Binary Tree
- Balanced Binary Tree
- Binary Tree From Inorder And Preorder
- Binary Tree From Inorder And Postorder
- Serialize Binary Tree
- Next Pointer Binary Tree
- Equal Tree Partition
🟠LCA, Paths & Distances
- Least Common Ancestor
- Path To Given Node
- Path Sum
- Diameter Of Binary Tree
- Max Sum Path In Binary Tree
- Node Distance C In Binary Tree
- Distance Between Nodes Of BST
🔴 Binary Search Trees (BST)
- Valid Binary Search Tree
- Sorted Array To Balanced BST
- BST Nodes In A Range
- Recover Binary Search Tree
- Kth Smallest Element In BST
- Two Sum BST
- Floor And Ceil In BST
- Check For BST With One Child
- Binary Tree To Circular Doubly Linked List
🟣 Tries (Prefix Trees)
- Spelling Checker
- Auto Complete
- Shortest Unique Prefix
- Maximum XOR
- Maximum XOR Subarray
- Contact Finder
- Modified Search