红黑树的插入后恢复平衡真的最多只需2次旋转么?

发布于 2022-09-05 15:37:00 字数 792 浏览 8 评论 0

" 1 " is the newest insert node. It is Case 1:current node is red, father is red, uncle is red.

So we set father'color as black, uncle's color as black, father's father's color as red, and set father's father as the current node, and continue to go.

After the above operations, it is case 1 again.

Let's imagine: if it is always becomes to be case 1, the numbers of rotate will not just 2, maybe more.

My above statements are right? I want to confirm my thinking.

转自:https://stackoverflow.com/que...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦初醒的夏天 2022-09-12 15:37:00

我有发表关于红黑树的文章,讲解很详细

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文