-
Notifications
You must be signed in to change notification settings - Fork 176
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
平衡二叉树 | HZFE - 剑指前端 Offer #53
Comments
解法二 -> 思路 -> 其中的描述: "上面的方法是自顶而上" , 可能会造成困惑. 解法一中从根节点开始遍历, 直观来看二叉树呈现出来的数据结构形状, 该处写为 "自顶而下" 或者 "从根节点遍历到树的末端" 可能更通顺些 |
树相关遍历使用yield 性能更好一些,https://www.30secondsofcode.org/articles/s/js-data-structures-binary-tree |
yield性能好在哪 |
“该方法由于使用了递归,并且每次递归都调用了两次自身,导致会函数栈会按照等差数列开辟", 关于两个算法空间复杂度分析这里,个人认为是O(n),首先从文章的理解来说,等差数列就是一个1+2+4+8+...+2n就也还是一个O(n),其次两个算法当树退化至链表时最差递归空间才到n,也就是从根节点到最后一个节点的栈空间都保存着,空间复杂度怎么也无法到O(n^2)。 |
@fpandzc 是的这里的空间复杂度确实是O(n), 空间复杂度主要取决于递归调用的层数,递归调用的层数不会超过 n |
@Akiq2016 这里应该得修正下 |
平衡二叉树 | HZFE - 剑指前端 Offer
题目描述
https://febook.hzfe.org/awesome-interview/book1/algorithm-balanced-binary-trees
The text was updated successfully, but these errors were encountered: