Suppose there is a tree:
1
/ \\
2 3
/ \\
4 5
Then the mirror image will
Here is my function. Do suggest if any better solution:
void mirrorimage(struct node *p)
{
struct node *q;
if(p!=NULL)
{
q=swaptrs(&p);
p=q;
mirrorimage(p->left);
mirrorimage(p->right);
}
}
struct node* swaptrs(struct node **p)
{
struct node *temp;
temp=(*p)->left;
(*p)->left=(*p)->right;
(*p)->right=temp;
return (*p);
}