• recategorized by
942 views
0 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$

1 Answer

0 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:
Position:
Show:

Related questions

0 0 votes
1 1 answer
627
627 views
admin asked Jan 5, 2019
627 views
The preorder traversal sequence of a binary search tree is $25, 15, 10, 4, 12, 22, 18, 24, 50, 35, 31, 44, 70, 66, 90$Which one of the following is the postorder traversa...
0 0 votes
1 1 answer
697
697 views
admin asked Jan 5, 2019
697 views
Consider that $\text{N}$ distinct elements $(\text{N}>3)$ are inserted into an initially empty binary search tree $\text{(BST)}.$ Which of the following statements are tr...
0 0 votes
1 1 answer
858
858 views
admin asked Jan 5, 2019
858 views
Consider the following array of elements$<70, 23, 60, 19, 13, 16, 1, 4, 8, 12, 7, 10, 85>$The minimum number of interchanges needed to convert into a max-heap is $4$$1$$3...
0 0 votes
3 3 answers
895
895 views
admin asked Jan 5, 2019
895 views
The following function attempts to merge two sorted linked lists. ListNode is the custom structure representing a node in the linked list.ListNode* Merge(ListNode* pHead1...