如何生成尽可能不平衡的AVL树?
我在一些论文中看到这一点,有人认为当我们删除 AVL 树的节点时最多可以有 log(n) 次旋转。我相信我们可以通过生成尽可能不平衡的 AVL 树来实现这一目标。问题是如何做到这一点。这对我研究移除旋转的事情有很大帮助。非常感谢!
I saw this in some paper and someone argued that there can be at most log(n) times rotation when we delete a node of an AVL tree. I believe we can achieve this by generating an AVL tree as lopsided as possible. The problem is how to do this. This will help me a lot about researching the removal rotation thing. Thanks very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想制作一棵最大不平衡的 AVL 树,你需要寻找斐波那契数列树,归纳定义如下:
例如,这是一个 5 阶斐波那契树:
斐波那契树代表最大值AVL 树可以具有的倾斜量,因为如果平衡因子更加不平衡,每个节点的平衡因子将超过 AVL 设定的限制树。
您可以使用这个定义非常容易地生成最大不平衡的 AVL 树:
希望这会有所帮助!
If you want to make a maximally lopsided AVL tree, you are looking for a Fibonacci tree, which is defined inductively as follows:
For example, here's a Fibonacci tree of order 5:
The Fibonacci trees represent the maximum amount of skew that an AVL tree can have, since if the balance factor were any more lopsided the balance factor of each node would exceed the limits placed by AVL trees.
You can use this definition to very easily generate maximally lopsided AVL trees:
Hope this helps!