• retagged by
689 views
0 0 votes

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 true?

  1. None of the above
  2. The worst case height of the resulting $\text{BST}$ is $\log_{2}\text{N}$
  3. Consider that a given order of insertion results in a $\text{BST}$ of height $ \text{N}.$ One can always find two elements in the original order where swapping the order of insertion of the two elements can half the height of the resulting $\text{BST}.$
  4. Swapping the order of insertion of any two elements can always half the height of the resulting $\text{BST}.$

1 Answer

0 0 votes

Same is explained in testBook testSeries :

Concept:

Binary search tree:

A binary search tree, also called an ordered or sorted binary tree, is a rooted binary tree data structure whose internal nodes each store a key greater than all the keys in the node’s left subtree and less than those in its right subtree.

Option B: The worst-case height of the resulting BST is log2N.

False, If there are n nodes in a binary search tree, the maximum height of the binary search tree is n-1 and the minimum height is ceil(log2n). If the binary search tree has height n, a minimum number of nodes is n+1 (in the case of left-skewed and right-skewed binary search trees). So worst-case height of the resulting binary search tree is O(n).

Option D: Swapping the order of insertion of any two elements can always be half the height of the resulting BST.

False, Swapping the order of insertion of any two elements will not be always half the height of the resulting BST.

Option C: Consider that a given order of insertion results in a BST of height N. One can always find two elements in the original where swapping the order of insertion of the two elements can half the height of the resulting BST.

True,

Hence the correct answer is C : Consider that a given order of insertion results in a BST of height N. One can always find two elements in the original where swapping the order of insertion of the two elements can half the height of the resulting BST.

• edited by
Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
620
620 views
admin asked Jan 5, 2019
620 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
939
939 views
admin asked Jan 5, 2019
939 views
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}$ b...
0 0 votes
1 1 answer
854
854 views
admin asked Jan 5, 2019
854 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
888
888 views
admin asked Jan 5, 2019
888 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...