A visual, interactive guide to understanding General Trees, Binary Trees, and Binary Search Trees — and how they relate to each other.
A tree is a hierarchical data structure made of nodes connected by edges. It has exactly one root, and every other node has exactly one parent. A node can have any number of children.
Hover over any node. Notice: nodes can have 0, 1, 2, 3+ children — no limit!
A Binary Tree is a special tree where every node has at most 2 children — called the left child and the right child. No ordering rule exists on the values.
Every node has ≤ 2 children. Values (7, 2, 15 …) are placed without any ordering rule.
A BST is a Binary Tree with one extra rule: for every node, all values in the left subtree are smaller and all values in the right subtree are larger. This enables fast O(log n) search.
Every BST is a Binary Tree, and every Binary Tree is a Tree — but not the other way around. They form a strict subset chain.
| Property | Tree | Binary Tree | BST |
|---|---|---|---|
| Max children per node | Unlimited | 2 | 2 |
| Values ordered? | No | No | Yes |
| Search complexity | O(n) | O(n) | O(log n)* |
| Left / Right distinction | No | Yes | Yes |
| Example use | File systems, DOM | Expression trees | Databases, indexes |
* O(log n) average; O(n) worst case if unbalanced.