Consider a binary search tree (BST) with leaf nodes . Given any node , the key present in the node is denoted as . All the keys present in the given BST are distinct. The keys belong to the set of real numbers.
For a node , let denote the node that is its inorder successor. If a node does not have an inorder successor, then is . As there are no duplicates, if is not , then .
Corresponding to every leaf node that has a non-NULL , a new key with the following property is to be inserted into the BST.
Let represent the list of all such new keys to be inserted into the BST.
Which of the following statements is/are true?
View worked solution
Answer: A;C
Let the sorted order of all keys in the BST be .
- Statement A is TRUE: Each leaf node corresponds to some unique element in the sorted sequence. Its inorder successor is the next element . The key is chosen from the open interval . Since all leaf nodes are distinct, their corresponding indices are distinct. The open intervals for distinct are mutually disjoint, meaning no two keys in can be equal. Thus, cannot have any duplicates.
- Statement B is FALSE: If the BST consists of a single node (which is a leaf), its inorder successor is . In this case, is empty and has elements.
- Statement C is TRUE: For any leaf , the key lies strictly between and . During BST insertion, the search path for will follow the exact same path as . Upon reaching , since , it will be inserted as the right child of . Since each leaf gets at most one child at depth , the maximum depth (height) of the tree can increase by at most .
- Statement D is FALSE: Consider a BST with root , left child , and right child . The leaves are and . Only leaf has a non-NULL successor (). Thus, only one key is inserted, increasing the total number of nodes from to , which is not double.
Free practice · Your answers on this page are not saved.
