Red - Black - Tree (1) 1
Red - Black - Tree (1) 1
K.SOUMYA REDDY
23H51A66Y5
Introduction to Red Black Tree
Red Black Tree is a self-balancing binary
search tree that maintains balance during
insertions and deletions.
1
Rules for Red Black Tree
Rule 1: Every node is either red or black.
Rule 2: The root node of the tree is always black.
Rule 3: Red nodes have black children.
3
Rules for Red Black Tree
Rule 5: Every path from a node to its descendant NULL nodes has the
same number of black nodes.
Rule 6: Red nodes cannot have red children.
4
Insertion in Red Black Tree
1. if tree is empty ,create a newnode node as root
node with colour black.if tree is not empty,create
a newnode as leafnode with red colour.
2.if parent of newnode is black then exit.
Then if parent of newnode is red ,then check the
colour of parents siblings of newnode .
5
SEARCHING:-
Search Steps:-
• Repeat: Continue this process until the target value is found or a NIL node is reached
6
Advantages of Red Black Tree
Red Black Tree offers guaranteed logarithmic
time complexity of for search, insert, and delete
operations.
Red blacktrees are self-balancing.
7
Applications of Red Black Tree
Red Black Tree is commonly used in the
implementation of language compilers, symbol
tables, and databases.
It is also used in data structures like TreeMap in
Java and set data structures in C++.
Red black trees are used in the implementation
of game engines
9
THANK YOU
10