What is a Binary Tree?
A Binary Tree is a hierarchical structure built from nodes, where every node has at most two children, conventionally called the left and right child. That two-child limit is what separates it from a general tree, and it's what makes every property below meaningful and calculable.
Key Terminology
Height, Depth & Level
Height and depth are the two measurements that come up constantly when reasoning about a tree's performance — most tree operations run in time proportional to the height, not the number of nodes, which is exactly why keeping a tree balanced matters so much.
In this tree, node A sits at depth 0 (the root), B and C sit at depth 1, and D, E, F, G all sit at depth 2. Since the deepest node is at depth 2, the tree's height is 2.
Node Count Formulas
| Property | Formula |
|---|---|
| Max nodes at depth d | 2^d |
| Max total nodes for height h | 2^(h+1) − 1 |
| Min total nodes for height h | h + 1 |
| Min possible height for n nodes | ⌊log₂ n⌋ |
Why Balance Matters
- Balanced tree, n = 7 nodes → height = 2 (as close to log₂ 7 as possible)
- Skewed tree, n = 7 nodes → height = 6 (every node has exactly one child)
- Same node count, wildly different performance — height is what actually matters
Complexity Implications
Since most tree operations (search, insert, delete) walk from the root down to a leaf, their time complexity is O(height) — O(log n) for a balanced tree, degrading to O(n) for a skewed one.
Time Complexity Analysis
Space Complexity for storing a binary tree with n nodes is O(n), since each node needs a fixed amount of memory (its value plus two child pointers) regardless of the tree's shape.
These structural properties aren't just theory — they're what a balancing algorithm (like in AVL or Red-Black trees) is actively trying to protect. A tree that's allowed to grow unchecked can degrade to the same O(n) worst case as a linked list.