Insertion of node into AVL tree carried out - Data Structure

Q.  How is an insertion of a node into an AVL tree carried out?
- Published on 27 Aug 15

a. By treating an AVL tree as a binary search tree
b. By updating the balance factors working upward from insertion point to the root
c. Both a & b
d. None of the Above

ANSWER: Both a & b
 

    Discussion

  • Nirja Shah   -Posted on 18 Nov 15
    For insertion of a node into an AVL tree following point should be consider.
    - By treating an AVL tree as a binary search tree
    - By updating the balance factors working upward from insertion point to the root
    Insertion of a node into an AVL tree is similar to binary search tree. For inserting new node, first we have to search the position and then insert the node at its proper position. After insertion, the balance might be change. We already know that balance factor in AVL tree are -1, 0, 1. So the balance factor of any node become other than these value, then we have to restore the property of AVL tree to achieve permissible balance factor.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)