Saturday, August 2, 2008

C Code for Mirror Image Tree

void mirror(struct node* node) {

if (node==NULL) {

return;
}
else {

struct node* temp; // do the subtrees
mirror(node->left); mirror(node->right); // swap the pointers in this node
temp = node->left;
node->left = node->right;
node->right = temp;
}
}

No comments:

Your Title