Docsity

AVL Tree Imbalance Types and Corresponding Rotations, Study notes of Algorithms and Programming

Toggle sidebar
bg1
AVL Tree Node Violation:
The Four Weiss Violation Types โ€” Sahni's Notation Included1
I. Left subtree has a height two greater
than the right subtree, and at the left child,
the two subtrees are of equal height or the left
subtree has a height one greater than the
right.
A single right rotation at the point of
violation will suffice.
Sahni: LL type imbalance
II. Left subtree has a height two greater
than the right subtree, and at the left child,
the right subtree has a height one greater
than the left.
There must be a set-up rotation at the left
child to the left. After that is the rightward
rotation at the point of violation.
Sahni: LR type imbalance
III. Right subtree has a height two greater
than the left subtree, and at the right child,
the left subtree has a height one greater than
the right.
There must be a set-up rotation at the right
child to the right. After that is the leftward
rotation at the point of violation.
Sahni: RL type imbalance
IV. Right subtree has a height two
greater than the left subtree, and at the
right child, the two subtrees are of
equal height or the right subtree has a
height one greater than the left.
A single left rotation at the point of
1 Mark Allen Weiss, Data Structures & Algorithm Analysis in C++ (2nd edition; Addison-Wesley, 1999), pp.
145 ff.
Sartaj Sahni, Data Structures, Algorithms, and Applications in Java (2nd edition, Silicon Press, 2005), pp. 607 ff.
Printed on 2020-11-29 at 15:31
pf2

Partial preview of the text

Download AVL Tree Imbalance Types and Corresponding Rotations and more Study notes Algorithms and Programming in PDF only on Docsity!

AVL Tree Node Violation:

The Four Weiss Violation Types โ€” Sahni's Notation Included

1 I. Left subtree has a height two greater than the right subtree, and at the left child, the two subtrees are of equal height or the left subtree has a height one greater than the right. A single right rotation at the point of violation will suffice. Sahni: LL type imbalance II. Left subtree has a height two greater than the right subtree, and at the left child, the right subtree has a height one greater than the left. There must be a set-up rotation at the left child to the left. After that is the rightward rotation at the point of violation. Sahni: LR type imbalance III. Right subtree has a height two greater than the left subtree, and at the right child, the left subtree has a height one greater than the right. There must be a set-up rotation at the right child to the right. After that is the leftward rotation at the point of violation. Sahni: RL type imbalance IV. Right subtree has a height two greater than the left subtree, and at the right child, the two subtrees are of equal height or the right subtree has a height one greater than the left. A single left rotation at the point of (^1) Mark Allen Weiss, Data Structures & Algorithm Analysis in C++ (2nd (^) edition; Addison-Wesley, 1999), pp. 145 ff. Sartaj Sahni, Data Structures, Algorithms, and Applications in Java (2nd edition, Silicon Press, 2005), pp. 607 ff. Printed on 2020-11-29 at 15:

violation will suffice. Sahni: RR type imbalance Printed on 2020-11-29 at 15: