Right-left case – double rotation to the left

The right-left case is the inverse of the left-right 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 left-heavy. In this case, we can fix it by doing a right rotation on the right child, which results in the right-right case, then we fix it again by doing a left rotation on the unbalanced node, as demonstrated in the following diagram:

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

Suppose node 35 was the ...

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.