Red/Black Trees

In computer science, a red–black tree is a kind of self-balancing binary search tree. Each node stores an extra bit representing “color”, used to ensure that the tree remains balanced during insertions and deletions.

These are a translation of a 2-3 tree (see below).

In practice: Red–black trees offer worst-case guarantees for insertion time, deletion time, and search time. Not only does this make them valuable in time-sensitive applications such as real-time applications, but it makes them valuable building blocks in other data structures which provide worst-case guarantees; for example, many data structures used in computational geometry can be based on red–black trees, and the Completely Fair Scheduler used in current Linux kernels uses red–black trees. In the version 8 of Java, the Collection HashMap has been modified such that instead of using a LinkedList to store identical elements with poor hashcodes, a Red-Black tree is used.

Visit the following resources to learn more: