Issue in taking the input

I am unable to understand what is true and false for. With context to the input given, can someone explain how the tree would structurally look like?

10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false
10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false

Or at least suggest how the input function should be?
Thanks in advance…

@sagnik.pal2017 your buildtree() function would be formed in the different way unlike the usual like you consider string data instead of int data(usual way) and string data can store all values required by the input in the form of string(like “false” ,“true”, “10”) rest of the logic can be structured easily.
if you still have any doubt you can reply further

I have tried to make the buildTree() function here is the code link:

Definitely something is wrong here as it is not works, pls help me with this.
Thanks in advance…

nodebuildtree()
{
string str;
cin>>str;
if(str==“false”)
{
return NULL;
}
if(str==“true”)
{
string d;
cin>>d;
node
root=new node(d);
root->left=buildtree();
root->right=buildtree();
return root;
}
node*root=new node(str);
root->left=buildtree();
root->right=buildtree();
return root;
}
buildtree() function we go this way and in the defination of class declare string data not int data

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.

1 Like

But in the sample input we first need to take the node value as the input and then take the boolean input

i m saying take everything int form of strings numbers as well as “true” and “false”