Binary Trees
Properties
- Max no.of nodes at ‘l’ level = 2l
- Max total no.of nodes in a ‘h’ height tree = 2h - 1
- Min no.of levels in a ‘n’ nodes tree = log2n+1
Types of Traversals
- Inorder (DFS) : Left → Root → Right
- Preorder (DFS) : Root → Left → Right
- Postorder (DFS) : Left → Right → Root
- Level Order Traversal (BFS) : Level after level
Types of Trees
- Fully/Proper Binary Tree—each node has either 0 or 2 children
- Binary Search Tree : left.val < root.val < right.val
- Degenerate/Pathological Tree—every node has a child (like linked-list performance wise)
- Skewed Binary Tree—either only left nodes or only right nodes