1. AA Trees
Red-Black trees simplified
20PT25 – Rhubanraj P 20PT27 – Sai Shreehamsini N
November 21, 2021
PSG College of Technology
1
2. Table of contents
1. Introduction
2. Recapitulation – Balanced BST
3. Properties of AA Trees
in terms of RB Trees
4. Pseduo-nodes
5. Properties of AA Trees
in terms of Pseudo-nodes
6. Balancing Operations
2
4. How is the simplicity achieved?
• Traditional balancing methods replaced by Skew and Split
• Balance information is represented as one bit per node
• Deletion is done using two global pointers
Is there a tradeoff?
Simpler and clearer but slower than Red-Black trees.
3
6. Balanced BST
Height?
The maximum level of its leaves. Also known as the depth.
Balance factor?
Balance of a node is defined as the height of its left subtree minus
the height of the right subtree
When does the tree become balanced?
Balance factor of every node is either -1, 0 or 1.
4
8. Properties
• Every node in the AA Tree is colored either Red or Black
• The Root should be Black
• If a node is a red node, its children must be black.
• All Simple paths from any node x to its descendant leaf nodes
must contain the same number of black nodes.
• Left children may not be red.
5
9. Properties (Cond...)
• Leaf nodes are nodes that contain no black children.
• Level of a Node.
• 1, if it is a leaf Node.
• Level of the parent, if the node is red.
• One less than the level of the parent, if the node is black.
• Red children are considered to be in the same level as its parent.
6
10. RB Trees - AA Trees Example
4
2
1 3
10
6
5 8
7 9
12
11 13
Figure 1: An AA Tree (RB Tree Depiction)
7
12. Abstraction using pseudo-nodes
• Pseudo-nodes are used in a binary search tree to fake a
multi-way search tree
• Red-black abstraction is removed; ”Red” links considered
horizontal and ”black” links considered vertical
• Horizontal links correspond to a single pseudo-node
• Vertical links correspond to two pseudo-nodes
8
16. Properties
1. Every path contains the same number of pseudo-nodes.
2. A left child may not have the same level as its parent.
• Alternatively, horizontal left links are not allowed.
3. Two right children with the same level as the parent are not
allowed.
• Alternatively, two consecutive horizontal links are not allowed.
11
18. Balancing Operations – Skew
What does the skew operation do?
A skew removes left horizontal links by rotating right at the parent
Is there any change to the levels?
No, because the operation simply turns a left horizontal link into a
right horizontal link.
12
21. Balancing Operations – Split
Why do we need the split operation?
A skew could create two consecutive right horizontal links, which is
not allowed.
What does the operation do?
A split removes consecutive horizontal links by rotating left and
increasing the level of the parent
Is there any change in the levels?
Yes, a split needs to change the level of a single node because if a
skew is made first, a split will negate the changes made by doing the
inverse of a skew. The new parent is forced to a higher level.
15