error on running
/bin/run.sh: line 4: 17 Segmentation fault (core dumped) ./exe
what mistake i am doing in taking the input
@toshitvarshney11 hey we have to take levelwise input of tree not woth recursion ,pls check the input format yiu will get it.
i am having problem in thinking how to buildtree from levelwise input please share the code with explanation.
@toshitvarshney11 hey ,In Level Order, you insert the nodes/traverse the tree level wise.
i.e.
first node at level 0(Root)
then you start filling the next level i.e. level 1 from left to right
Similar order is followed for other nodes.
Let’s understand with the help of example given in the question:
1 2 3 4 5 -1 6 -1 -1 -1 -1 -1 -1
-1 indicates no child.
The structure of the tree formed for the above example is:
_________________1
_________2______________3
_____4_______5_______________6
refer to this code:
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.