Data Structure Notes
Some notes while revisiting data structure and algorithms, after 4 years.
Trees
Some concepts:
- Depth of a node: Number of edges from the root to that node.
Height of a node: Number of edges on the longest path from that node down to a leaf.
- Height of a tree: Height of the root (longest root-to-leaf path).
- Tree node’s degree: Number of children the node has.
- Predecessor: The node that comes immediately before another in a traversal or ordering (commonly the in-order predecessor in BSTs).
- Successor: The node immediately after.
- Lowest Common Ancestor (LCA): The deepest node that is an ancestor of both given nodes.
- Perfect binary tree: Every internal node has exactly 2 children and all leaves are at the same depth.
- Complete binary tree: All levels are full except possibly the last, which is filled from left to right.
- Full / Strict binary tree: Every node has either 0 or 2 children (no node has exactly one).