I am unable to understand what exactly we have to provide in input and how the tree is built from input
Please explain me the input format
hi @KetanPandey firstly you are given input for the node right, then a string is provided. If that string is “true” then that means that left subtree exists and you have to call the function to build the left subtree, if it is false then that means that left subtree does not exist and you can leave it as NULL. Similarly, after left tree will be built, a string indicating whether right child exists or not is provided.
Please tell me why this code is giving wrong answer,its giving correct answer in dry run.Link:https://ide.codingblocks.com/s/306433
Please correct this code so that it passes all the test cases
@KetanPandey hey correct your input function like this:
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;
}
}
but in input format given in question,its first asking integer value than string
Yes but in the code that you have provided above,where r u taking input for string
My code is somewhat same.Please tell whats the problem in this code:https://ide.codingblocks.com/s/307318
Ketan, pls refer to the chat… I have explained the input and how can you build the tree