160 likes | 207 Vues
Internal Path Reduction Tree. IPR. IPR Trees are with no doubt superior compared to AVL Trees.
E N D
IPR Trees are with no doubt superior compared to AVL Trees There are many variations of balanced and semi-balanced 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. IPR
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 IPR
Single right rotation X Nc> Na a Y IPR c b More Nodes to The Left of X
Double right rotation X Nb> Na a Y IPR c b b1 b2 More Nodes to The Left of X
Before Rotation MoreNodes to The Left of X (SRR) 2Nc+IPc+2Nb+IPb+Na+IPa+3 IPR 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 IPR After Rotation 2Nc+IPc+2Nb1+IPb1+2Nb2+IPb2 +2Na+IPa+5 IP1 > IP2 Nb > Na
Single Left Rotation X a Y IPR Nc > Na c b More Nodes to The Right of X
Double Right Rotation X Nb> Na a Y IPR b c b1 b2 More Nodes to The Left of X
20 17 11 20 17 11 IPR
11 5 14 8 15 16 17 20 11 5 14 IPR 8 15 16
16 11 5 17 20 8 14 IPR 15 16
16 11 5 17 20 8 15 IPR 14 16
Summary of Worst Case Complexities AVL IPR IPR <=1.4402 log2n <=1.4402 log2n Height >=1.2793 nlog2n 1.0515 nlog2n Internal Path Length