剑指offer-二叉树的镜像

题目描述:操作给定的二叉树,将其变换为源二叉树的镜像。

输入描述:

二叉树的镜像定义:源二叉树 
    	    8
    	   /  
    	  6   10
    	 /   / 
    	5  7 9 11
    	镜像二叉树
    	    8
    	   /  
    	  10   6
    	 /   / 
    	11 9 7  5
ac代码:
 1 /**
 2 public class TreeNode {
 3     int val = 0;
 4     TreeNode left = null;
 5     TreeNode right = null;
 6 
 7     public TreeNode(int val) {
 8         this.val = val;
 9 
10     }
11 
12 }
13 */
14 public class Solution {
15     public void Mirror(TreeNode root) {
16         if(root==null)
17             return ;
18         TreeNode t=root.left;
19         root.left=root.right;
20         root.right=t;
21         Mirror(root.left);
22         Mirror(root.right);
23     }
24 }
 
原文地址:https://www.cnblogs.com/llsq/p/8796332.html