Question:medium

Suppose the values 10, −4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree. Let \( T \) be the resulting binary search tree. The number of edges in the path from the node containing 19 to the root node of \( T \) is \underline{{1cm}}. {(Answer in integer)}

Show Hint

In a Binary Search Tree (BST), the depth of a node is the number of edges from the root to that node.
Updated On: Jan 30, 2026
Show Solution

Correct Answer: 4

Solution and Explanation

After inserting all the given values, observe the relative ordering of the keys. The value 19 is smaller than 20 but larger than 15, placing it in the subtree rooted at 20, which itself lies under 30 and 15.

Tracing upward from 19, the sequence of ancestors encountered before reaching the root 10 is:

\(19 \rightarrow 20 \rightarrow 30 \rightarrow 15 \rightarrow 10\)

This traversal involves four parent-child connections.

Hence, the distance from node 19 to the root is \(\boxed{4}\).

Was this answer helpful?
0

Top Questions on Trees