AVL tree vs RB tree with applications
AVL tree vs RB tree with applications What is AVL Tree? In 1962, GM Adelson - Velsky and EM Landis invented the AVL Tree. The tree is named AVL after its creators. The AVL Tree is a height balanced binary search tree in which each node has a balance factor that is calculated by subtracting the height of its right sub-tree from the height of its left sub-tree. If the balance factor of each node is between -1 and 1, the tree is said to be balanced; otherwise, the tree is unbalanced and must be balanced. Balance Factor (k) = height (left(k)) - height (right(k)) If balance factor of any node is 1, it means that the left sub-tree is one level higher than the right sub-tree. If balance factor of any node is 0, it means that the left sub-tree and right sub-tree contain equal height. If balance factor of any node is -1, it means that the left sub-tree is one level lower than the right sub-tree. The figure below depicts an AVL tree. We can see that the balance...