in DS edited by
22,494 views
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)?

  1. $2$
  2. $3$
  3. $4$
  4. $6$
in DS edited by
22.5k views

6 Answers

41 votes
41 votes
Best answer

Height is 3

Correct Answer: $B$

edited by

10 Comments

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
0
They didn't mention in the question, they are only saying use a empty binary search tree.
0
0
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
1
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
1
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
1
Why We are not balancing tree at node one factor will -2 so after balancing height will result as 2 ???
0
0
they dint say that root is at height 0 right?? then how do you consider it
1
1
only height is asked not any other so wee need not to do it
0
0
They did not tell us to balance it. Balancing is carried out if it is mentioned that it is an AVL tree.
0
0
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
0
9 votes
9 votes

ans is (b)

2 Comments

what tool did you use bro to draw this ? Kinda curious
0
0
1
1
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.
5 votes
5 votes
ans will be 3 . hence option (b)
by
Answer:

Related questions