AA TREE
hello!
I am Amanda Rozi Kurnia
I am here to give presentation about “AA tree”
My NRP 05111940000094
2
1.
Definition of AA Tree
Let’s start with the definition of AA Tree.
3
“
An AA tree in computer science is a form of
balanced tree used for storing and retrieving
ordered data efficiently. AA trees are named for Arne
Anderson, their invertor.
AA trees are variation of the red-black trees, a
form of binary search tree which supports efficient
addition and deletion of entries.
4
“
The maintenance algorithms for a red-black tree need
to consider seven different shapes to properly balance
the tree
An AA tree on the other hand only needs to consider
two shapes due to the strict requirement that only
right links can be red
5
Big concept
These parts will explain about the
concept of an AA Tree
6
CONCEPT OF AA TREE
AA tree use the concept of levels to The level of every leaf node is
aid in balancing binary trees. The one.
level of node (instead of colour) is The level of red nodes are same
used for balancing information. A link as the level of their parent nodes
where child and parent’s levels are and the links are called horizontal
same, is called a horizontal link, and links.
is analogous to a red link in the red-
The level of black nodes are one
black tree.
less than the level of their parent
node.
7
AA Tree’s explanation
An AA tree follows same Why AA Tree?
rule as red-black trees with The implementation and
the addition of single new number of rotation cases
rule that red nodes cannot in Red-Black Trees is
be present as left child. Every path from root to complex. AA tree simplifies
Every node can be a NULL node has same the algorithm.
either red (linked number of black nodes It eliminates half of the
horizontally) or black. (or black links) restructuring process
There are no two Left link cannot NOT be by eliminating half of
adjacent red nodes (or red (horizontal) (New the rotation cases,
horizontal links). added rule) which is easier to code.
It simplifies the deletion
process by removing
multiple cases.
8
AA TREE’s EXAMPLE
Note that in the tree, there are
no left red child which is the
White new added rule of AA Trees.
9
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:
10
BALANCING ROTATIONS
Whereas red-black trees require one bit of balancing metadata per node (the
color), AA trees require O(log(log(N))) bits of metadata per node, in the form
of an integer "level". The following invariants hold for AA trees:
The level of every leaf node is one.
The level of every left child is exactly one less than that of its parent.
The level of every right child is equal to or one less than that of its parent.
The level of every right grandchild is strictly less than that of its
grandparent.
Every node of level greater than one has two children.
11
Insertions and deletions may transiently cause an AA
tree to become unbalanced (that is, to violate the AA
tree invariants). Only two distinct operations are needed
for restoring balance: "skew" and "split".
Skew is a right rotation to replace a subtree
containing a left horizontal link with one containing a
right horizontal link instead. Split is a left rotation and
level increase to replace a subtree containing two or
more consecutive right horizontal links with one
containing two fewer consecutive right horizontal links.
Implementation of balance-preserving insertion and
deletion is simplified by relying on the skew and split
operations to modify the tree only if needed, instead of
making their callers decide whether to skew or split.
12
SKEW SPLIT
13
INSERTION
Insertion begins with the normal binary
tree search and insertion procedure. Then, as
the call stack unwinds (assuming a recursive
implementation of the search), it's easy to
check the validity of the tree and perform any
rotations as necessary.
If a horizontal left link arises, a skew will
be performed, and if two horizontal right links
arise, a split will be performed, possibly
incrementing the level of the new root node of
the current subtree.
14
DELETIONS
As in most balanced binary trees, the deletion of an
internal node can be turned into the deletion of a leaf
node by swapping the internal node with either its closest
predecessor or successor, depending on which are in the
tree or on the implementor's whims.
Retrieving a predecessor is simply a matter of
following one left link and then all of the remaining right
links. Similarly, the successor can be found by going right
once and left until a null pointer is found. Because of the
AA property of all nodes of level greater than one having
two children, the successor or predecessor node will be in
level 1, making their removal15 trivial.
To re-balance a tree, there are a few approaches. The
one described by Andersson in his original paper is the
simplest, and it is described here, although actual
implementations may opt for a more optimized approach.
After a removal, the first step to maintaining tree
validity is to lower the level of any nodes whose children
are two levels below them, or who are missing children.
Then, the entire level must be skewed and split. This
approach was favored, because when laid down
conceptually, it has three easily understood separate steps:
Decrease the level, if appropriate.
Skew the level.
Split the level.
16
PERFORMANCE
The performance of an AA tree is equivalent to the
performance of a red-black tree. While an AA tree
makes more rotations than a red-black tree, the
simpler algorithms tend to be faster, and all of this
balances out to result in similar performance. A red-
black tree is more consistent in its performance than
an AA tree, but an AA tree tends to be flatter, which
results in slightly faster search times
17
Let’s review some concepts
So, in summarized way, for tree to be AA tree, it must
satisfy the following five invariants:
The level of leaf node is 1.
The level of left child is exactly one less than of its
parent.
The level of every right child is equal to or one less
than of its parent.
The level of every right grandchild is strictly less
than that of its grandparent.
Every node of level greater than one has two
children. 18
thanks!
Any questions?
You can find me at
mandasan37@[Link]
19