树相关的问题一般都是递归
public class Solution {
public boolean isSymmetric(TreeNode root) {if(root==null)return true;
return isMirror(root.left,root.right);
}
public boolean isMirror(TreeNode p,TreeNode q){
if(p==null&&q==null)return true;
if(p==null||q==null)return false;
if(p.val==q.val&&isMirror(p.left,q.right)&&isMirror(p.right,q.left))return true;
else return false;
}
}