A tree data structure in which each node has at most two child nodes.
Binary trees are data structures in which each node has at most two child nodes, called the left child and the right child of the node.
Nodes with children are called parent nodes, the node without a parent is called the root node, while nodes with no children are called leaf nodes.
The level of a node is how far it is below the root node; the height of a node is how far it is above the furthest leaf.
One use of binary trees is efficient searching and sorting (e.g. binary search tree). The properties of trees mean nodes can be found quickly and compared easily, especially for trees which are balanced. (A tree is balanced if and only if the left and right subtrees of every node differ in height by no more than 1).
Types of binary trees
- Full binary tree
- Complete binary tree
- Perfect binary tree
- Balanced binary tree
- Degenerate binary tree
- Root binary tree