Given a Binary Tree, convert it into its mirror.
分析:程序分为3个大的部分。
- 什么情况下可以结束
- 交换左右节点
- 递归
private TreeNode mirrorRecursively(TreeNode root1) {
if(root1 == null || (root1.left==null && root1.right==null))
return root1;
TreeNode temp = root1.left;
root1.left = root1.right;
root1.right = temp;
mirrorRecursively(root1.left);
mirrorRecursively(root1.right);
return root1;
}