my code is not giving any output for creation of tree using preorder and inorder . can you plzz tell why??
link:https://ide.codingblocks.com/s/112382
Create tree using inorder and preorder
when i did for(int j=s;s<=e;j++) it is still giving error
hey @khushi91200, you tree is built correctly, it is giving error because of print function. Here is logic of print function. Change your code according to that
void print(node* root)
{
if(root==NULL)
{
return;
}
if(root->left!=NULL&&root->right!=NULL)
{
cout<left->data<<" => β<data<<β <= "<right->data<<endl;
}
else if(root->left==NULL&&root->right!=NULL)
{
cout<<βEND => β<data<<β <= β<right->data<<endl;
}
else if(root->left!=NULL&&root->right==NULL)
{
cout<left->data<<β => β<data<<β <= ENDβ<<endl;
}
else
{
cout<<βEND => β<data<<β <= ENDβ<<endl;
}
print(root->left);
print(root->right);
}