###### 【Leetcode】Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

For example, this binary tree is symmetric:

    1
/ \
2   2
/ \ / \
3  4 4  3


But the following is not:

    1
/ \
2   2
\   \
3    3


Note:
Bonus points if you could solve it both recursively and iteratively.

	boolean result = true;
public boolean recur(TreeNode root){
if(root!=null){
if(satisfy a condition){
result = false;
}
recur(root.left);
recur(root.right);
}
return result;
}


	public boolean isSym(TreeNode p, TreeNode q) {
if (p == null && q == null) {//都为空
return true;
}else if (p == null || q == null) {//有一个不为空
result = false;
}else if (p.val == q.val) {
isSym(p.left, q.right);//注意对称
isSym(p.right, q.left);
} else {
result = false;
}
return result;
}

public boolean isSymmetric(TreeNode root) {
if (root == null) {
return true;
}
if (root.left == null && root.right == null) { //单结点
return true;
}
if (root.left == null || root.right == null) {//不对称
return false;
}
return isSym(root.left, root.right);
}

boolean result = true;

#### 【LeetCode】101. Symmetric Tree 解题报告

2016-05-30 23:06:35

#### LeetCode(101)Symmetric Tree

2014-01-17 06:48:54

#### Symmetric Tree -- LeetCode

2014-04-07 04:52:23

#### 【leetcode c++】101 Symmetric Tree

2015-07-27 14:39:02

#### Leetcode-Symmetric Tree——判断二叉树是否对称

2014-04-20 01:00:22

#### 【LeetCode-面试算法经典-Java实现】【101-Symmetric Tree（对称树）】

2015-08-07 07:29:25

#### 101. Symmetric Tree Leetcode Python

2015-01-30 07:28:30

#### leetcode上令人拍案叫绝的解法

2017-03-27 22:17:54

#### 【LeetCode】Symmetric Tree 解题报告

2016-05-08 15:01:08

#### leetcode 之 Symmetric Tree 镜像树

2014-08-26 10:55:10

## 不良信息举报

【Leetcode】Symmetric Tree