Binary trees

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 successorrespectively. 

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 3and 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 right successor

A regular binary tree has no other rules as to how elements are arranged in the tree. It should only satisfy the condition that each node should have a maximum of two children.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset