First-invented self-balancing binarysearch tree Named after its two inventors,1. G.M. Adelson-Velsky and2. E.M. Landis,› published it in their 1962 paper "Analgorithm for the organization ofinformation."
First, its a binary search tree... L <= P and P <= RRLP
Is this a binary tree search tree?3 9515 211728 343243 514652 545358 6860 71 797712 35 5629 7050
An AVL tree is a balanced binary tree To understand balance we need tounderstand the notion of Tree Height5532 7164 86 Height 0Height 1Height 2
By default, nodes with no children havea height of Height of 0.5532 7164 86 Height 0Height 1Height 2Height0Height 0
But, we must also understand theconcept of Sub-trees5532 7164 86Height 0 Height 1Height 2Height 0 Height 0sub-tree L has aheight of 0 sub-tree R has aheight of 1Height = max(L.height, R.height) + 1
Also empty sub-trees have a Height of -1445891Height = 2 = max(0, 1) + 1Height = 0 = max(-1,-1) + 1Height = max(L.height, R.height) + 1Height = 1 = max(-1, 0) + 1
Anyway, the AVL Balance Property is asfollows... For ALL nodes, the Height of the Left andRight Sub-trees can only differ by 1.P A NodeL R1.. heightRheightL
1. After every insertion2. Check to see if an imbalance wascreated.• All you have to do backtrack up the tree3. If you find an imbalance, correct it.4. As long as the original tree is an AVLtree, there are only 4 types ofimbalances that can occur.