一个红黑案例问题

发布于 2024-08-17 21:25:21 字数 283 浏览 5 评论 0原文

我试图理解红黑树是如何工作的,假设图中从第一个到第二个的过渡,我得到它没有任何问题,之后根据教学资源,我需要对红色 G 节点进行本地修复。 那么作为第二步的修复,G 是否只是简单地着色为黑色以保持红黑属性?

替代文本 http://img683.imageshack.us/img683/4929/rb1.jpg< /a>

谢谢

I am trying to understand how red black trees work, assume the transition from first to the second at the picture, I get it this without any problem, after this according to teaching resources, I need to do a local fix on the red G node.
So as a fix to the 2nd step, does G simply colored to black to maintain the red-black properties ?

alt text http://img683.imageshack.us/img683/4929/rb1.jpg

thanks

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

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

发布评论

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

评论(1

北座城市 2024-08-24 21:25:21

经典的定义说根必须是黑色的,因此必须将其涂成黑色才能获得该属性。基本思想是在某些位置禁止红色节点(例如作为另一个红色节点的子节点),因此将节点绘制为红色会创建应检查的潜在约束违规。

The classic definition says the root has to be black, so it would have to be painted black to get that property. The basic idea is that red nodes are forbidden in certain locations (such as being a child of another red node), so painting a node red creates a potential constraint violation that should be checked for.

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