AVL Insertion

Learn about the insertion operation in AVL trees and all four insertion cases.

Introduction

Insertion in AVL trees is done the same way that BST insertion is done. However, when a node is inserted into a BST, it usually becomes unbalanced, i.e., the tree has a node that has a left-right subtree height difference greater than 1. So, AVL trees have to be rebalanced after insertion unlike BSTs. To rebalance the tree, you need to perform a ‘rotation’. But before ...