Posts

Showing posts from May, 2020

AVL Tree

AVL Tree is a self balancing binary tree that changes when a new node is inserted. This makes it faster to search for a specific node. INSERTION There are 4 cases for tree balancing if a new node is inserted: Case 1 : the deepest node is located at the left sub tree of the left child of T. Case 2 : the deepest node is located at the right sub tree of the right child of T. Case 3 : the deepest node is located at the right sub tree of the left child of T. Case 4 : the deepest node is located at the left sub tree of the right child of T. there are 2 types of rotations in tree balancing, single rotation and double rotation. the following is all the possible rotation variant: LL rotation: the new node is inserted in the left sub-tree of the left sub-tree of the critical node RR rotation: the new node is inserted in the right sub-tree of the right sub-tree of the critical node. LR rotation: the new node is inserted in the right sub-tree of the left sub-tree of the criti...