Binary Tree Construction

Whenever I enter false for any node having left sub node , the code runs over all the other input statements.
code : https://ide.codingblocks.com/s/104195
driver code :https://ide.codingblocks.com/s/104196

test output :
Enter Data for Root node
50
Do you have left child of 50
false
Do you have right child of this node 50
End =>50<=End

choice = false;
System.out.println("Do you have right child of this node "+ node.data);
if(choice)
{
node.right = takeInput(s, node, false);
}
return node;

For the right child, you have hardcoded ‘choice’ as false, but you have to take input from the user and if the user says true then you have to make the call for right child. So, remove “choice= false” and after the print statement add “choice = s.nextBoolean();” just like you’ve done for the left child.

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.