in DS recategorized by
541 views
0 votes
0 votes

We create a binary search tree $\text{B}_{1}$ by inserting the numbers $1,2,3,4,5$ into an empty binary search tree. We create another binary search tree $\text{B}_{2}$ by inserting the numbers into an empty binary search tree in the reverse order. What is the difference between the right-most element of $\text{B}_{2}$ and the left-most element of $\text{B}_{2}$?

  1. $2$
  2. $3$
  3. $1$
  4. $4$
in DS recategorized by
by
541 views

1 Answer

0 votes
0 votes

Rightmost Element of BST= Largest Number

Left most Element of BST= Smallest Number

Rightmost of BST(B1)=5 and Leftmost of BST(B2)=1

Difference=5-1

=4,So D is the correct answer.

Binary Search tree(B1) with 1,2,3,4,5             &                   Binary Search Tree(B2) with 5,4,3,2,1

1                                                                                                               5

   2                                                                                                        4

      3                                                                                                 3

          4                                                                                          2

              5                                                                                 1

Answer:

Related questions