二叉树的镜像
二叉树的镜像
http://www.nowcoder.com/questionTerminal/564f4c26aa584921bc75623e48ca3011
public class Solution {
public void Mirror(TreeNode root) {
//递归返回条件
if(root==null){
return;
}
//存下来左右结点
TreeNode tempLeft = root.left;
TreeNode tempRight = root.right;
//交换
root.left = tempRight;
root.right = tempLeft;
//左递归
Mirror(tempLeft);
//右递归
Mirror(tempRight);
}}