[LinkedIn] Mirror of a binary tree
Given a binary tree, return the mirror of it.
Very easy. Recursion
TreeNode mirror(TreeNode root) {
if (root == NULL)
return NULL;
else {
TreeNode newNode = new TreeNode(root.val);
newNode->left = mirror(root->right);
newNode->right = mirror(root->left);
return newNode;
}
}