0
14kviews
What is AVL tree? Construct AVL tree for the following data. Mention the type of rotation for each case. 50, 25, 10, 5, 7, 3, 30, 20, 8, 15

Mumbai University > COMPS > Sem 3 > Data Structures

Marks: 10 M

Year: May 2015

1 Answer
1
911views
  • AVL is self-balancing binary tree named after Adelson-Velsky-Landis, its founders.
  • In AVL tree, the difference in height of two nodes is at the most one.
  • AVL trees are similar to binary search trees, except that there is an extra variable associated with every node called as the Balance_factor. The value of balance_factor is calculated as

    $$\text{Balance_factor=Height of left Sub tree- Height of Right Sub tree.}$$

  • If balance_factor =1; the tree is said to be left-heavy
  • If balance_factor=0; the tree is stable
  • If balance_factor=-1;the tree is right-heavy
  • If balance_factor >1 or balance_factor < -1; The tree is unbalanced and the node is called as critical node. We need to balance by using one of the four rotation methods

enter image description here

enter image description here

enter image description here

Please log in to add an answer.