Transcript IPR Trees

IPR Trees are with no doubt superior
compared to AVL Trees
There are many variations of balanced and semibalanced binary trees. One of them, which is due to
the work of Gaston H. Gonnet published in 1983, is
the Internal Path Reduction (IPR) tree. Its height is
the same as the AVL tree, but produces a slightly
more compact structure. The internal path (IP) is
defined as the sum of the path lengths of all nodes
measured from the root. On average, the IPR tree
produces an internal path of about 10% smaller
than the AVL one.
In addition, the IPR tree has a tunable parameter
that determines the acceptable level of imbalance.
AVL vs. IPR



Both are BSTs
Both are HB(1)
They do not tolerate imbalance and the tree is restored to a
proper shape by predefined rotations.

IPR rotations are geared towards reducing IP in the tree
(IP = Σpath length from Nodei to root i=1 to n )

AVL has attracted much more attention in the literature but
IPR is kinda forsaken
Single right rotation
X
Nc > Na
Y
c
a
b
More Nodes to The Left of X
Double right rotation
X
Nb > Na
Y
c
a
b
b1
b2
More Nodes to The Left of X
More Nodes to The Left of X (SRR)
Before Rotation
2Nc+IPc+2Nb+IPb+Na+IPa+3
After Rotation
Nc+IPc+2Nb+IPb+2Na+IPa+3
IP1 > IP2
Nc > Na
More Nodes to The Left of X (DRR)
Before Rotation
2Nc+IPc+3Nb1+IPb1+3Nb2+IPb2 +Na+IPa+6
After Rotation
2Nc+IPc+2Nb1+IPb1+2Nb2+IPb2 +2Na+IPa+5
IP1 > IP2
Nb > Na
Single Left Rotation
X
Nc > Na
Y
a
b
More Nodes to The Right of X
c
Double Right Rotation
X
Nb > Na
Y
a
b
c
b1
b2
More Nodes to The Left of X
11
17
20
20
17
11
11
14
15
16
5
8
17
20
11
5
14
8
15
16
16
11
5
17
8
20
14
15
16
16
11
5
17
8
20
15
14
16
Summary of Worst Case
Complexities
AVL
Height
Internal Path Length
IPR
<=1.4402 log2n
<=1.4402 log2n
>=1.2793 nlog2n
1.0515 nlog2n