An AVL (Adelson-Velskii and Landis) Tree is a self balancing Binary Search Tree which has the following properties.
For any node “A”, the height of the left subtree of “A” and height of the right subtree of “A” differ by 1 at max.
For every node in an AVL Tree, the difference between the height of its left subtree and right subtree should not be more than 1. Whenever insertion makes a node unbalanced, AVL rotations are used to balance the tree again.
In this article, let’s look into the Right-Left Rotation, also called RL Rotation.
In case of Binary search Trees worst case search complexity is O(n) in cases when the Binary Search Tree is skewed. In AVL tree, since heights of left and right subtree are balanced, hence search complexity improves to O(log n). Before going ahead have a look into AVL Tree Basics.
(more…)