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 ___________. (Answer in integer)
Answer
4
Explanation
Insert the keys in order, going left for a smaller key and right for a larger one:
- 10 is the root; \(-4\) goes left of 10 and 15 right of 10.
- 30 goes right of 15, and 20 goes left of 30.
- 5 goes right of \(-4\), and 60 goes right of 30.
- 19 is larger than 10 and 15 but smaller than 30 and 20, so it becomes the left child of 20.
The path from 19 up to the root is \(19 \to 20 \to 30 \to 15 \to 10\): 4 edges, i.e. 19 sits at depth 4.
Answer: 4