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

" 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...

阅读 3.9k
1 个回答

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题