Search code examples
algorithmdata-structuresred-black-tree

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


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


Solution

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