I am having a hard time figuring out how the tree looks like with the given inputs. Please tell me how does this level order input lead to the construction of a tree.
1 2 3 4 5 6 -1 -1 -1 -1 -1 -1 -1
TREE BOTTOM VIEW - Doubt
Basically, you will give input as 1, which will be your root node. To build tree levelwise, you need to take a queue, push the data, and then pop the element present , and before popping add its children, -1 here denotes that there is no child, thus 2 and 3 becomes left and right child of tree with root 1, then 4 and 5 will be left and right child of tree with root node as 2 and then 6 will become left child of 3, right child of 3 will be -1… In this way you have to build your tree.
How are the integers 4 2 6 3 in the bottom view. Would’n only the end nodes 4 5 6 be visible from the bottom?
No, you are getting wrong, for this question you will calculate the different horizontal distances from root node,
Thus based on tht you will have following values :
L1 : 4 , hd= -2
L2 : 2 hd=-1
L3 : 1,5,6 hd=0
L4 : 3, hd= +1
Based on this the last values of all L1 TO L5 , i.e 4,2,6, 3
what is l?? and what is hd??
hd will be your horizontal distance, and L1 to L4 represents the levels…