Binary trees
Introduction / Definition
A binary tree is a rooted tree in which each node has at most two children, commonly called left and right children. Binary trees support efficient searching, expression representation, and recursive algorithms. They are not necessarily complete or balanced. Different shapes can have very different heights.
Syntax / Mathematical Form
Each node has at most two children: left and right
Detailed Explanation
A binary tree can be empty or have a root with left/right subtrees. Recursive definitions make traversal algorithms natural. In a perfect binary tree of height h, the number of nodes is 2^{h+1}−1.
Example / Worked Example
A root 10 has left child 5 and right child 15.
Output / Result
The tree has 3 nodes and height 1.
Important Points / Notes
- At most two children.
- Left/right position matters.
- Balanced trees can provide efficient operations.
Mini Practice Question
Draw a binary tree containing 7 nodes.