NIMCET 2021 — Computer PYQ
NIMCET | Computer | 2021The given numbers are inserted into an empty binary search tree in the given order: 10,1,3,5,15,12 and 16. What is the height of the binary search tree.
Choose the correct answer:
- A.
3
(Correct Answer) - B.
4
- C.
5
- D.
6
3
Explanation
A Binary Search Tree (BST) follows the rule: for any given node, values smaller than the node go to the left, and values greater go to the right.
Insert 10: Becomes the Root node.
Insert 1: Since 1 < 10, it goes to the left of 10.
Insert 3: Since 3 < 10 and 3 > 1, it goes to the right of 1.
Insert 5: Since 5 < 10, 5 > 1, and 5 > 3, it goes to the right of 3.
Insert 15: Since 15 > 10, it goes to the right of 10.
Insert 12: Since 12 > 10 and 12 < 15, it goes to the left of 15.
Insert 16: Since 16 > 10 and 16 > 15, it goes to the right of 15.
Tree Structure Visualized:
Plaintext
10
/ \
1 15
\ / \
3 12 16
\
5
Height Calculation Analysis:
Depending on the standard or exam convention being used, height can be defined in two ways:
Edge-Based Definition (Standard/Highlighted Option):
Height is defined as the maximum number of edges from the root node to a leaf node.
Longest path: 10→1→3→5
Number of edges = 3 (Option A)
Node-Based Definition (Alternative Level Convention):
Height is defined as the maximum number of nodes on the longest path from the root node to a leaf node.
Longest path: 10,1,3,5
Number of nodes = 4 (Option B)
Since Option A is the marked key for this specific evaluation, the height is counted via the number of edges, giving 3.
