How should i take the inputs?
How should i take the inputs?
hello @haseebshaik00

first read root node.
then check whether left subtree exist or not by reading a string .
if it is true that means left subtree exist ,so build left tree recursively
otherwise assign NULL to left of current node.
again read one more string to check whether right subtree exist or not.
if it exist(string is true) then build it recursively
otherwise
assign NULL to right of current node
and at the end return current node
but how will i know that the current tree’s input is over
u dont have to, the recursive call will stop on its own.
for understanding check this simple example->
1 false false
u will read 1 ,u will make it as root .
now u will read false that indicates left subtree does not exist so no call will be made here
again u will read false that indicates right subtree does not exist so no call will be made here
and the control will return on its own to the calling function.
one last doubt does input 10 true 20 means
one last doubt does input 10 true 20 means 10 is root true means leftroot exist and its value is 20 or it means 10 is root true means leftroot exist and the right root value is 20?
yeah this is correct
10 is root true means leftroot exist and its value is 20
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.