I am not able to take binary tree input as the code is not working correctly. Can you please error in buildTree() function. Only the root node is showing while printing.
Binary tree input
Hi ashutosh
class node
{
public:
string data;
nodeleft;
noderight;
node(string d)
{
data=d;
left=NULL;
right=NULL;
}
};
nodebuildtree()
{
string str;
cin>>str;
if(str==“false”)
{
return NULL;
}
if(str==“true”)
{
string d;
cin>>d;
noderoot=new node(d);
root->left=buildtree();
root->right=buildtree();
return root;
}
node*root=new node(str);
root->left=buildtree();
root->right=buildtree();
return root;
}