How to get Mirror Image of a Binary Search Tree?

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 ;
struct tnode *temp;
return p;

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: