Red-Black Trees in Data Structure

Data StructureAnalysis of AlgorithmsAlgorithms

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.

raja
Published on 11-Aug-2020 06:35:26
Advertisements