cannot figure out the input taking of the q
How to code the input format
hi @neelrai906 i have fixed your buildTree() function have a look. There are logical errors in your kthlevel function, do a dry run once to figure it out.
node* buildTree(){
int d,child;
cin>>d>>child;
node*root=new node(d);
if (child == 0) {
return root;
}
root->left=buildTree();
if (child == 2) {
root->right=buildTree();
}
return root;
}
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.