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

二叉树 #6

Open
funnycoderstar opened this issue Aug 21, 2018 · 0 comments
Open

二叉树 #6

funnycoderstar opened this issue Aug 21, 2018 · 0 comments
Labels
Tree

Comments

@funnycoderstar
Copy link
Owner

二叉树的深度

二叉树的深度,也叫二叉树的高度,二叉树的深度等于从根结点到叶子结点的最长路径加1。
用递归的观点来看,二叉树的深度,等于其最大左右子树的深度加1,而每个左子树(右子树)又可以分解为次左子树+次右子树,它们是深度也是最大子树深度加1。

二叉树的宽度

二叉树的宽度:具有结点数最多的那一层的结点个数。
采用分层遍历的方法求出所有结点的层编号,然后,求出各层的结点总数,通过比较找出层结点数最多的值。

二叉树b的叶子结点个数

当b为空树时,叶子结点数为0;
当b的左子树和右子树都为空,b只有一个结点时,叶子结点数为1;
当b的左子树或右子树不为空时,叶子结点数=左子树叶子结点数+右子树叶子结点数。

参考

javascript 二叉树(Trees)算法与说明

@funnycoderstar funnycoderstar added the Tree label Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tree
Projects
None yet
Development

No branches or pull requests

1 participant