CST370 Design and Analysis of Algorthms Week 6
This week we learn about AVL tree.One problem with binary search tress is that if the tree is too unbalanced or skewed, the operation can be linear time. The AVL tree is a balanced binary search tree, and the difference in height between left and right subtrees is either -1, 0 or 1. The difference is called the balance factor which is height of the either the left subtree and the height of the right subtree. AVL tree uses rotation as its operations. A rotation is a local transformation of a subtree whose balance factor has become either +2 or -2. In other words after inserting a new node, if the AVL tree becomes unbalanced, rotations are applied to restore balance. The four rotations are Right rotation, Left rotation, LR rotation and RL rotation. Another topic that was discuss is 2-3 trees. A 2-3 tree is a search tree where each node can have oen or two values (2-node or 3-nodes) All leaves are at the same level. We also discuss about Heap and Heapsort. A complete binary tre...