有没有一种简单的方法可以记住红黑树的旋转方法?

发布于 2024-09-10 05:33:46 字数 30 浏览 1 评论 0原文

有没有一种简单的方法可以记住红黑树的旋转方法?

Is there an easy way to remember the rotation methods for red-black trees?

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

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

发布评论

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

评论(2

客…行舟 2024-09-17 05:33:46

也许他们正在寻找 2-3-4 树(2 级 B 树)和红黑树的等价关系?

我一直发现 B 树中的插入比红黑树中的插入更容易理解。

请参阅此处的页面: http://www.eli .sdsu.edu/courses/fall95/cs660/notes/RedBlackTree/RedBlack.html

无论如何,你可能可以当场导出所需的旋转,一旦你熟悉了,这并不难和他们在一起。

Perhaps they are looking for the equivalence of 2-3-4 trees (B-trees of degree 2) and red-black trees?

I have always found insertion in B-Trees easier to understand than insertion in red-black trees.

See the page here: http://www.eli.sdsu.edu/courses/fall95/cs660/notes/RedBlackTree/RedBlack.html

In any case, you can probably just derive the rotations needed on the spot, it is not really that hard, once you have been familiar with them.

你与昨日 2024-09-17 05:33:46

不。没有办法记住!!(好吧,不是真的,但对于你如何利用自己的时间来说,这是最合适的答案)。

你知道吗?没有人需要能够背诵精确的旋转机制。 即使是少数人需要实现这些,也需要记住它们!请参阅Java的TreeMap实现,是一棵红黑树,搜索“From CLR”。他们基本上是复制粘贴代码,这正是正确的操作过程

No. There is no way to remember!! (Well, not really, but it is the most appropriate answer with regards to your use of your own time).

You know what? Nobody needs to be able to recite the exact mechanics of the rotations. Not even the handful of people required to implement these, need to remember them! See Java's implementation of TreeMap, which is a red-black tree, and search for "From CLR". They basically copy-pasted the code, which is exactly the proper course of action here.

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