If we are given input in the following form
1 2 3 4 5 -1 6 -1 -1 -1 -1 -1 -1
every time it gets -1 , that node is NULL.
How to build tree using level order traversal?
Hey @Manan-Kapila-2828762173851763
Level order input is taken and tree is build by using the queue, in which firstly u will take a queue of nodes, and then it will have a data which will represent a root node, and then u will accept the left and right child of root node, -1 value means that the node does not have any child.
U can refer to this code for your help(it contains the function for level order input)
1 Like
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.