剑指offer:二叉树镜像

题目描述:

操作给定的二叉树,将其变换为源二叉树的镜像。

输入描述:

二叉树的镜像定义:源二叉树 
    	    8
    	   /  
    	  6   10
    	 /   / 
    	5  7 9 11
    	镜像二叉树
    	    8
    	   /  
    	  10   6
    	 /   / 
    	11 9 7  5
 1 public class Jingxiang {
 2     public void Mirror(TreeNode root) {
 3         if(root == null) return;
 4         if(root.left==null&&root.right==null){return;}
 5         TreeNode temp = root.left;
 6         root.left = root.right;
 7         root.right = temp;
 8         if(root.left!=null)
 9             Mirror(root.left);
10         if(root.right!=null)
11             Mirror(root.right);
12         
13     }
14     public static void main(String[] args) {
15         // TODO Auto-generated method stub
16 
17     }
18 
19 }