Computer Sciences > GATE 2025 SET-2 > Binary Search Trees
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)
Correct : 3
The correct answer is 3.
Let's build the BST by inserting values in order: 10, -4, 15, 30, 20, 5, 60, 19.
— 10 → Root
— -4 → less than 10, left child of 10
— 15 → greater than 10, right child of 10
— 30 → greater than 10, greater than 15, right child of 15
— 20 → greater than 10, greater than 15, less than 30, left child of 30
— 5 → less than 10, greater than -4, right child of -4
— 60 → greater than 10, greater than 15, greater than 30, right child of 30
— 19 → greater than 10, greater than 15, less than 30, less than 20, left child of 20
So the path from node 19 → 20 → 30 → 15 → 10 (root).
That's 4 nodes and 3 edges - which is the answer.
Similar Questions
You are given a set V of distinct integers. A binary search tree T is created by inserting all elements of V one by one, starting with an empty tree. The tree T...
A palindrome is a word that reads the same forwards and backwards. In a game
of words, a player has the following two plates painted with letters.
From...
Which number does not belong in the series below?
2, 5, 10, 17, 26, 37, 50, 64
Total Unique Visitors
Loading......