Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

The four types of imbalance that can occur in an avl tree and the corresponding rotations needed to rebalance the tree. The document references mark allen weiss's 'data structures & algorithm analysis in c++' and sartaj sahni's 'data structures, algorithms, and applications in java'.

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-atz-1
koofers-user-atz-1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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: