二叉树的镜像
递归,交换结点的左右子树结点
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public void mirror(TreeNode root) {
if (root == null)
return;
mirror(root.left);
mirror(root.right);
TreeNode temp = root.left;
root.left = root.right;
root.right = temp;
}
}