Unable to construct binary tree from given input

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

Mohit, here true means having a child and false means there is no child… So you can take a node value and a string value … and then based on these two values, you can build your tree as,

node *buildtree(node *&root)
{
if(x==0)
{
x++;
int k;
cin>>k;
root=new node(k);
root->left=buildtree(root->left);
root->right=buildtree(root->right);
return root;
}
else
{
string str;
cin>>str;
int d;
if(str==“true”)
{
cin>>d;
node *temp=new node(d);
temp->left=buildtree(temp->left);
temp->right=buildtree(temp->right);
return temp;
}
else
if(str==“false”)
{
return root;
}
}
return root;
}