27 votes 27 votes The following numbers are inserted into an empty binary search tree in the given order: $10, 1, 3, 5, 15, 12, 16$. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)? $2$ $3$ $4$ $6$ DS gatecse-2004 data-structures binary-search-tree easy isro2009 + – Kathleen asked Sep 18, 2014 edited Dec 18, 2017 by kenzou Kathleen 22.4k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 41 votes 41 votes Height is 3 Correct Answer: $B$ Prashant. answered Nov 15, 2015 edited Jul 7, 2019 by Lakshman Bhaiya Prashant. comment Share Follow See all 10 Comments See all 10 10 Comments reply scarz commented Oct 17, 2018 reply Follow Share Why are we not balancing the tree when the elements are inserted into the tree? Won't it be a balanced binary search tree of height 2? 0 votes 0 votes Swapnil Naik commented Nov 5, 2018 reply Follow Share They didn't mention in the question, they are only saying use a empty binary search tree. 0 votes 0 votes Golam Murtuza commented Jul 17, 2019 reply Follow Share Root node is at height 0 or 1.nothing mentioned here,answer can be 3 or 4 depend upon that Or i am missing something? 1 votes 1 votes Akash Papnai commented Nov 5, 2019 reply Follow Share It is clearly mentioned: the height is the maximum distance of a leaf node from the root. Therefore, count the edges from root to maximum height. 1 votes 1 votes Manjyot Singh Nanra commented Dec 31, 2019 reply Follow Share Its like finding distance between two nodes in graph. there are 3 hops to reach lowest leaf node. Also we can look it like there are 3 edges in betweeen. 1 votes 1 votes Akanshaashu commented Mar 1, 2020 reply Follow Share Why We are not balancing tree at node one factor will -2 so after balancing height will result as 2 ??? 0 votes 0 votes RACHAPUDI JAGADEESH commented Jun 10, 2021 reply Follow Share they dint say that root is at height 0 right?? then how do you consider it 1 votes 1 votes RACHAPUDI JAGADEESH commented Jun 10, 2021 reply Follow Share only height is asked not any other so wee need not to do it 0 votes 0 votes Swiss commented Oct 6, 2021 reply Follow Share They did not tell us to balance it. Balancing is carried out if it is mentioned that it is an AVL tree. 0 votes 0 votes KhushiRastogi commented Jan 5, 2023 reply Follow Share because they are not saying to balance , they have not even mentioned the word in thewhole question . in gate pyq the answer is “ only for exactly what is asked “ 0 votes 0 votes Please log in or register to add a comment.
9 votes 9 votes ans is (b) kvkumar answered Jun 26, 2016 kvkumar comment Share Follow See all 2 Comments See all 2 2 Comments reply s_dr_13 commented Jul 17, 2020 reply Follow Share what tool did you use bro to draw this ? Kinda curious 0 votes 0 votes rhl commented Sep 21, 2021 reply Follow Share This https://www.cs.usfca.edu/~galles/visualization/BST.html 1 votes 1 votes Please log in or register to add a comment.
6 votes 6 votes Ans) 3 Draw a BST for the given numbers And the Distance from root(i.e 10) to leaf(i.e 5) is 3. Prasanna answered Nov 15, 2015 Prasanna comment Share Follow See all 0 reply Please log in or register to add a comment.
5 votes 5 votes ans will be 3 . hence option (b) anonymous answered Dec 21, 2014 anonymous comment Share Follow See all 0 reply Please log in or register to add a comment.