开发者

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

开发者 https://www.devze.com 2023-01-06 17:08 出处:网络
Is there开发者_JAVA技巧 an easy way to remember the rotation methods for red-black trees?Perhaps they are looking for the equivalence of 2-3-4 trees (B-trees of degree 2) and red-black trees?

Is there开发者_JAVA技巧 an easy way to remember the rotation methods for red-black trees?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消