Académique Documents
Professionnel Documents
Culture Documents
PRESENTATION
GROUP MEMBERS
AVL tree checks the height of the left and the right
subtree and assures that the difference is not more
than 1. An AVL tree is a self-balancing binary search
tree. This was the first data structure that was
invented and is named after their inventors.
Binary Search Tree is a node-based binary tree data structure which has
the following properties:
Node’s Left Child Must Have Value less than its parent value
Node’s Right Child Must have value greater than its parent value
The left and right subtree each must also be a binary search tree.
ALGORITHM FOR SEARCH IN BINARY SEARCH TREE
If root ==Null
Return Null
If Data==root Data
Return Root Data
If data < Root data
Return search(Root TO Left)
If Data > Root Data
Return Search (root TO Right)
HEIGHTED BALANCE TREE/AVL TREE
Insertion in AVL tree is performed in the same way as it is performed in the binary search tree. The new node is
added into AVL tree as the leaf node. However it may lead to violation in the AVL tree property and therefor tree
may need balancing.The tree can be balanced by applying rotations. Rotations is required only if the balance factor
of any node is disturbed upon inserting the new node otherwise the rotation is not required.
Example of insertion
Construct AVL tree by inserting the following data:
14,17,11,7,53,4,13,12,8,60,19,16,20.
DELETION IN AVL TREE.
Deleting a node from an AVL tree is similar to that in a binary search tree deletion may disturb the balance factor
of an AVL tree and therefore tree needs to be rebalanced in order to maintain the AVLness. For this purpose we
need to perform rotations. If the node which is to be deleted is present in the left subtree of the critical node
then l rotation needs to be applied else if ,the node which is to be deleted is present in the right subtree of the
critical node ,the R ROTATION WILL BE APPLIED.
Example of deletion
Construct AVL tree by deleting the following data :
8,7,11,14,17
AVL ROTATIONS
To balanced it self, an AVL tree may perform the following four kids of rotations
. left rotation
.right rotations
.left-right rotations
.right-left rotation
The first two rotations are single rotations and the next two rotations are double rotations. To have an
unbalanced tree, we least need a tree of height 2.
LEFT LEFT ROTATION
RIGHT RIGHT ROTATION
LEFT RIGHT ROTATION
RIGHT LEFT ROTATION
DISADVANTAGES OF HEIGHTED BALANCE TREE
AVL trees have both advantages and disadvantages over other self balancing trees.
AVL tree is slow because insertion of just one element makes it very slow.
Deletion operations cost high in AVL trees as they involve a lot of pointer changes and rotations.
The code of AVL tree is much more complex as compared to other BSTs.
AVL tree is also a time consuming process and slow down the function as well.
AVL tree would be a bad choice if you just need to time indexed any elements, let alone a balanced
tree to be used.
THANK YOU
ANY QUESTION?