Red-Black Trees in Data Structure

In this section we will see what is the Red-Black Tree. The Red-Black Trees are self-balancing binary search tree. There are some conditions for each node. These are like below −

  • Each node has color. Which is either Red or Black

  • The root will be always black

  • There will be no two adjacent Red nodes

  • Every path from a node (including root) to any of its descendent NULL node has the same number of black nodes.

Example of Red-black tree

Red-Black tree with Null Nodes at leaf

Comparison with AVL Tree

AVL Trees are more balanced than the Red-Black tree. But the major disadvantage is, there will be more rotations during insertion and deletion. For multiple insertion and deletion, Red-Black tree will be helpful.

Updated on: 11-Aug-2020


Kickstart Your Career

Get certified by completing the course

Get Started