5 votes 5 votes In what order we should insert the following elements into an empty AVL tree so that we don’t have to perform any rotation on it. 1, 2, 3, 4, 5, 6, 7 A. 4, 2, 1, 6, 3, 5, 7 B. 4, 2, 6, 1, 3, 5, 7 C. 6, 4, 5, 7, 1, 2, 3 D. 4, 5, 3, 2, 1, 6, 7 DS avl-tree + – pankaj_vir asked Mar 10, 2018 reopened Aug 9, 2018 by pankaj_vir pankaj_vir 923 views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply akash.dinkar12 commented Mar 10, 2018 reply Follow Share 4 2 6 1 3 5 7 0 votes 0 votes Sukanya Das commented Mar 10, 2018 reply Follow Share 4,2,6,1,3,5,7 option B) 1 votes 1 votes pankaj_vir commented Mar 10, 2018 reply Follow Share ans is correct 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes option B abhishekmehta4u answered Mar 11, 2018 selected Mar 11, 2018 by pankaj_vir abhishekmehta4u comment Share Follow See all 0 reply Please log in or register to add a comment.
2 votes 2 votes AVL Tree was the first balanced Binary Search Tree (BST). AVL tree is a Binary Search Tree, which is balanced with respect to the height of sub-trees.So, it is a height-balanced tree. A Binary Search Tree is a binary tree in which The keys in the left sub tree are smaller than the key in the root The keys in the right sub tree are larger than the key in the root Left and right sub trees are also Binary Search Trees. Now, in what order we should insert the {1,2,3,4,5,6,7} elements into an empty AVL tree so that we don’t have to perform any rotation on it. The order should be $\color{green}{\{4,2,6,1,3,5,7\}}$ In the above tree, the keys of the $\color{purple}{left-sub \hspace{0.1cm}tree\hspace{0.1cm} are\hspace{0.1cm} smaller\hspace{0.1cm} than\hspace{0.1cm} the\hspace{0.1cm} key\hspace{0.1cm} in\hspace{0.1cm} the \hspace{0.1cm}root}$ & $\color{purple}{the\hspace{0.1cm} keys\hspace{0.1cm} in\hspace{0.1cm} the\hspace{0.1cm} right\hspace{0.1cm} sub-tree\hspace{0.1cm} are\hspace{0.1cm} bigger\hspace{0.1cm} than\hspace{0.1cm} the\hspace{0.1cm} keys\hspace{0.1cm} in\hspace{0.1cm} the\hspace{0.1cm} root.}$ So, it is a Binary Search Tree. The above tree is also height-balanced . ∴ It is a AVL tree. Sukanya Das answered Mar 10, 2018 edited Mar 10, 2018 by Sukanya Das Sukanya Das comment Share Follow See all 0 reply Please log in or register to add a comment.