I am not able to understand the input format. Can you please explain me.
Doubt in the question
you have to take input in preorder format
first true means left subtree exist
second true means right subtree exits
false means doesn’t exists
node* buildTreePreOrder(){
int d;cin>>d;
node*n=new node(d);
string s;cin>>s;
if(s=="true"){
n->left=buildTreePreOrder();
}
cin>>s;
if(s=="true"){
n->right=buildTreePreOrder();
}
return n;
}
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.