Binary tree is a type of tree structure where each node contains upto 2 child nodes. A single node cant point to more than 2 nodes.
the above image is the example of binary tree as each node does not contain more than 2 nodes.
the above image can not be called binary tree as the root node-A, contains 3 child nodes which is more than 2, so its not a binary tree.
Strict Binary Tree-
Strict binary tree is a sub type of binary tree in which each node does not contain reference to more than 2 child nodes. The above figure is the example of strict binary tree.
Full Binary Tree-
Full binary tree is a sub type of binary tree in which each and every node should contain exactly 2 nodes. The above figure is the example of Full binary tree.
Each node of a binary tree has basically 2 sections, one stores the data and other stores the reference to the next nodes.
So in binary tree. there are 3 blocks, the middle block contains the data of the node, the left node contains the address of the left child node and the right block contains the address of the right child node.
In the above image, the structure of node A would be-
[[address of B] , data of A , [address of C]]
0 Comments