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 ______.
Correct Answer :
Solution :
The correct answer is 4.
To find the number of edges in the path from the node containing 19 to the root node, we can construct the Binary Search Tree (BST) by inserting the elements one by one. In a BST, for any given node, all elements in its left subtree are smaller than the node's value, and all elements in its right subtree are larger than the node's value.
Let's insert the values in the order they are given: 10, -4, 15, 30, 20, 5, 60, 19.
Step-by-step Insertion:
1. Insert 10: The tree is empty, so 10 becomes the root node.
2. Insert -4: Since -4 < 10, it goes to the left of 10. -4 becomes the left child of 10.
3. Insert 15: Since 15 > 10, it goes to the right of 10. 15 becomes the right child of 10.
4. Insert 30: Compare with 10 (30 > 10, go right), then compare with 15 (30 > 15, go right). 30 becomes the right child of 15.
5. Insert 20: Compare with 10 (20 > 10, go right), compare with 15 (20 > 15, go right), compare with 30 (20 < 30, go left). 20 becomes the left child of 30.
6. Insert 5: Compare with 10 (5 < 10, go left), compare with -4 (5 > -4, go right). 5 becomes the right child of -4.
7. Insert 60: Compare with 10 (60 > 10, go right), compare with 15 (60 > 15, go right), compare with 30 (60 > 30, go right). 60 becomes the right child of 30.
8. Insert 19: Compare with 10 (19 > 10, go right), compare with 15 (19 > 15, go right), compare with 30 (19 < 30, go left), compare with 20 (19 < 20, go left). 19 becomes the left child of 20.
Tracing the Path from Node 19 to the Root Node (10):
Following the parent pointers from the node containing 19 up to the root, we get:
19 → 20 → 30 → 15 → 10
Counting the edges (connections) in this path:
Edge 1: Between 19 and 20
Edge 2: Between 20 and 30
Edge 3: Between 30 and 15
Edge 4: Between 15 and 10
Therefore, the number of edges in the path from the node containing 19 to the root node is 4.
Access expert-curated educational resources and study materials—completely free.
Create, conduct, and manage professional online assessments with Mindyard. Perfect for teachers and institutes.
Copyright © 2026 Mindyard. All Rights Reserved.