COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
(4, 7)
|
|
(7, 4)
|
|
(8, 3)
|
|
(3, 8)
|
Detailed explanation-1: -The number of nodes in the left subtree and right subtree of the root respectively isa)(4, 7)b)(7, 4)c)(8, 3)d)(3, 8)Correct answer is option ‘B’. Can you explain this answer?. Solutions for A binary search tree is generated by inserting in order the following integers: 50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24.
Detailed explanation-2: -Binary search tree is a tree where the left subtree contains all the nodes smaller or equal to the root while right subtree contains the nodes greater than the root. Here number of items in the left subtree of root are 2 and number of items in the right subtree of root are 3.
Detailed explanation-3: -So the right subtree has max(, /2 − 1) nodes, i.e. max(1, 1) = 1. The left subtree has the remaining nodes, i.e. 3, so that 3 + 1 + 1 (for root) = 5.
Detailed explanation-4: -The total number of nodes is (N^L-1) / (N-1).
Detailed explanation-5: -Hence, 14 distinct binary search trees are possible for 4 keys.