Red/Black Trees
Last updated
What is 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.
Free resources to learn Red/Black Trees
More in stage 18: System Design
Red/Black Trees: common questions
Can I learn Red/Black Trees in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Red/Black Trees in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Red/Black Trees tutorial for beginners?
It is lesson 129 of 188 in the free Computer Science roadmap, in stage 18, System Design. If you are new to Computer Science, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.