How to read the input data? Unable to understand the true/false present
Unable to understand the input format
for this you have to use recursion
node* buildTree(){
int d;
cin>>d;
node*nn=new node(d);
string str;
cin>>str;
if(str=="true")nn->left=buildTree();
else nn->left=NULL;
cin>>str;
if(str=="true")nn->right=buildTree();
else nn->right=NULL;
}
Thanks. Could you please explain me how to read the true and false present in the input ?
i just shared the snippet with you .you can refer to this for the basic main and build function anyways:
also, a bit difficult to read the code you mentioned though!