The GATE Grind

GATE 2025 CS (CS2) – Question 35

Programming and Data Structures · Trees and Binary Search Trees · 1 mark · Numerical answer

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)

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 4

Explanation

Insert into an initially empty BST in this order: 10, $-4$, 15, 30, 20, 5, 60, 19.

Path from 19 to the root: $19\to20\to30\to15\to10$, which has **4** edges.

More Trees and Binary Search Trees questions

All Trees and Binary Search Trees questions →