What do you mean by Mirror image of a Binary tree? It means, another binary search tree that is a mirror image of the given one.

This is a recursive solution for this problem, just swap the left and right subtrees for each node recursively. Let me know if you have problem understanding it.

`struct tnode *mirror(struct tnode *p){`

if(p == NULL)

return p ;

else{

mirror(p->left);

mirror(p->right);

struct tnode *temp;

temp=p->left;

p->left=p->right;

p->right=temp;

}

return p;

}

Advertisements