Using preorder and inorder create tree


how to print like the output pattern please help?..

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.