A binary tree is one in which each node has a maximum of two children. The nodes in the binary tree are organized in the form of left sub-tree and right sub-tree. If the tree has a root, R, and two sub-trees, that is, left sub-tree T1, and right sub-tree T2, then their roots are called left successor and right successor, respectively.
The following diagram is an example of a binary tree with five nodes:
Here are the following observations that we have made regarding the preceding diagram:
- Each node holds a reference to a right and left node if the nodes do not exist
- The root node is denoted with 5
- The root node has two sub-trees, where the left sub-tree has one node, that is, a node with a value of 3, and the right sub-tree has three nodes with the values 7, 6, and 9
- The node with a value of 3 is a left successor node, whereas the node with a value of 7 is the...