Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symmetric Tree递归算法 #82

Open
Jinku opened this issue Feb 15, 2016 · 0 comments
Open

Symmetric Tree递归算法 #82

Jinku opened this issue Feb 15, 2016 · 0 comments

Comments

@Jinku
Copy link

Jinku commented Feb 15, 2016

_解题思路: 递归
这道题没什么特别的地方,现在这里简单的分析一下解题思路,从根节点往下,我们要判断三个条件.

  1. 左右两个节点的大小是否相同.
  2. 左节点的左孩子是否和右节点的右孩子相同.
  3. 左节点的右孩子是否和右节点的左孩子相同.
    ,如果以上三个条件对于每一层都满足,我们就可以认为这棵树是镜像树._

但这并不是树是对称树的所有条件,比如
1
/
2 2
/ \ /
1 2 2 1
/ \ / \ / \ /
1 3 3 1 1 2 2 1

所有的层都符合这三个条件,但显然不是对称树
下一层满足了条件,并不等于上层也满足。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant