Right-right case: single rotation to the left

The right-right case is the inverse of the left-left case. It occurs when the height of a node’s right child becomes greater than that of the left child, and the right child is either balanced or right-heavy, as demonstrated by the following diagram:

Let’s use a practical example. Consider the following diagram:

Suppose node 90 was the last one inserted in the AVL tree. This would make the tree unbalanced (node 50 -Y has a height of -2), so we would need to balance it. These are the steps we will ...

Get Learning JavaScript Data Structures and Algorithms - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.