二叉树的镜像

 1 public class Solution {
 2 
 3     public static void MirrorBinaryTree(TreeNode root) {
 4         if(root == null) {
 5             return;
 6         }
 7 
 8         if(root.left == null && root.right == null) {
 9             return;
10         }
11 
12         TreeNode tmp = root.left;
13         root.left = root.right;
14         root.right = tmp;
15 
16         if(root.left != null) {
17             MirrorBinaryTree(root.left);
18         }
19 
20         if(root.right != null) {
21             MirrorBinaryTree(root.right);
22         }
23     }
24 }

原文地址:https://www.cnblogs.com/wylwyl/p/10462017.html