Open In App

AA Trees | Set 1 (Introduction)

AA trees are the variation of the red-black trees, a form of binary search tree.

AA trees use the concept of levels to aid in balancing binary trees. The level of node (instead of colour) is used for balancing information. A link where child and parent’s levels are same, is called a horizontal link, and is analogous to a red link in the red-black tree.

Additional storage requirement with every node is O(Log n) in red black trees instead of O(1) (only color in Red Black Trees), but AA trees simplify restructuring by removing many cases.

An AA tree follows same rule as red-black trees with the addition of single new rule that red nodes cannot be present as left child.

  1. Every node can be either red (linked horizontally) or black.
  2. There are no two adjacent red nodes (or horizontal links).
  3. Every path from root to a NULL node has same number of black nodes (on black links).
  4. Left link cannot NOT be red (horizontal). (New added rule)

Why AA trees :
The implementation and number of rotation cases in Red-Black Trees is complex. AA trees simplifies the algorithm.

Below tree is the example of AA tree :

Note that in the above tree there are no left red child which is the new added rule of AA Trees.

After re-drawing the above AA tree with levels and horizontal links (the red nodes are shown connected through horizontal or red links), the tree looks like:

Note that all the nodes on level 1 i.e. 5, 10, 20, 35, 40, 55, 65, 80, 90 are known as leaf nodes.

So, in summarized way, for tree to be AA tree, it must satisfy the following five invariants:

Article Tags :