getting fault I think my code is correct
Identical binary tree
- in the build tree function

if child is not there, then why are you returning NULL? The root node should still exist.
And you have to see if child exists for both left child and right child.
corrected function:
node *buildbst()
{
int d;
string child;
cin >> d;
node *n = new node(d);
cin >> child;
if (child == "true")
n->left = buildbst();
cin >> child;
if (child == "true")
n->right = buildbst();
return n;
}
- You only have to see if the structure of the tree is same or not, you dont have to compare the values
@Ishitagambhir
I am returning NULL to n left or right na and atlast I am returning n which is the root.
@Ishitagambhir
we have to also store NULL at left or right na if its child is false?thats why I am returning nULL
if you return NULL first, then the flow of control will NEVER reach the line that is returning root, return statement means that the function ends right then and there.
Look at the correct function definition I mentioned and let me know if you have any doubts in that.
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.

