Multiple choice

Insert the following elements as binary search tree, 10, 11, 12, 13, 14, 15, 16, 17 and build AVL tree.

  1. 15

  2. 14

  3. 13

  4. 16

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

While inserting the element make sure the difference of height of  left subtree and right sub tree must be -1, 0 and +1. Insert 10 as a root, then 11 as right child. Here, tree is balanced. Now Insert 12, tree became unbalanced as the height of left sub tree from root and right sub tree is -2, 0 = -2. So do RR rotation on tree. Now 11 is as root and 10 as left child and 12 as right child. Again insert 13 as left child of 12, then 14 right child of 13 again it unbalanced. So do again RR rotation and so on.