..MindWrite..

Posts Tagged ‘mirror of a binary tree’

create Mirror of a Binary Tree

Posted by guptaradhesh on December 8, 2010

a solution pseudo-code to this using recursion is as:

mynode *createMirror (mynode *root)
{
mynode *temp;

if(root==NULL)return(NULL);

temp = (mynode *) malloc(sizeof(mynode));
temp->value = root->value;

temp->left = createMirror(root->right);
temp->right = createMirror(root->left);

return(temp);
}

Posted in puzzles/ algorithms | Tagged: , , | Leave a Comment »