how to print like the output pattern please help?..
Using preorder and inorder create tree
hey @Aryanomar00, this is the logic for printing in this manner
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);
}
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.