Question:

In a binary search tree with the following elements: \( 10, -4, 15, 13, 20, 5, 16, 19 \), the number of edges from node 19 to the root is?

Show Hint

When counting the number of edges from a node to the root in a binary search tree, simply trace the path from the node back to the root, counting each edge.
Updated On: Mar 18, 2025
  • 3
  • 4
  • 2
  • 5
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Step 1: Visualizing the Binary Search Tree (BST).

The given elements are \( 10, -4, 15, 13, 20, 5, 16, 19 \). We can build the BST as follows:


1. \( 10 \) is the root.
2. \( -4 \) goes to the left of \( 10 \).
3. \( 15 \) goes to the right of \( 10 \).
4. \( 13 \) goes to the left of \( 15 \).
5. \( 20 \) goes to the right of \( 15 \).
6. \( 5 \) goes to the right of \( -4 \).
7. \( 16 \) goes to the left of \( 20 \).
8. \( 19 \) goes to the right of \( 16 \).


Step 2: Traversing from node 19 to the root.


- The path from node 19 to the root is: \( 19 \to 16 \to 20 \to 15 \to 10 \).
- Therefore, the number of edges is 4.


Thus, the correct answer is \( 4 \).
Was this answer helpful?
1
0