Skip to content

Instantly share code, notes, and snippets.

@jagtesh
Created April 16, 2010 07:18
Show Gist options
  • Save jagtesh/368124 to your computer and use it in GitHub Desktop.
Save jagtesh/368124 to your computer and use it in GitHub Desktop.
// START //
struct node {
node *left;
node *right;
int val;
};
// Mirrors the tree and returns the root node. The root should be passes as *node.
node* mirror_tree(struct node* node) {
struct node* temp;
temp = node->left;
node->left = node->right;
node->right = temp;
// Call to the left
if (node->left != NULL)
mirror_tree(node->left);
// Call to the right
if (node->right != NULL)
mirror_tree(node->right);
return node;
}
// END //
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment