AVL Trees

When the elements are inserted in sorted order, the tree structure in a binary tree looks similar to that of linear linked list. Hence the operations like insertion and deletion will have O(n) time complexity. In such a case Avl Trees are used. In Avl tree, after every insertion it is checked whether the tree is balanced or not with the help of a height of a tree. Based on it the tree is rotated left or right.

In AVLtree.py , the function SettleViolation() will help to balance a tree after the insertion of every element. Now the Time Complexity of a Balanced Tree will be O(nlog(n)).