Consider the following binary search tree T given below: Which node contains the fourth smallest element in T?
Inorder traversal of BST sorts the elements in ascending order .
UQXWPVZY --> inorder traversal
4th smallest element is W.
The In-order traversal of BST gives number in sorted order
Here In-order traversal sequence is as follows
U Q X W P V Z Y
hence 4rth smallest will be W.
Hence Option C) W will be the answer.
Answer C) W
In BST left child is smaller than root value and right child is greater than root value.
1 st small = U
2 nd small = Q
3 rd small = X
4 th small = W option A
Answer : Option C ===> W
64.3k questions
77.9k answers
244k comments
80.0k users