If an internal node doesn't have a left child , then we can keep some marker at array index 2i+1 which can tell that there is no left child present for the parent internal node . Array representation is not usually used for storing binary trees (unless it is a heap) , since too much space is wasted if the tree is sparse and right skewed . Linked List representation is used in that case . @Shaik Masthan kindly rectify wherever i went wrong.
Left child = 2i , right child = 2i+1
Left child = 2i ,
right child = 2i+1
If array is start from index 1.
64.3k questions
77.9k answers
244k comments
80.0k users