Skip to main content

GATE CSE 2025Data Structures › Trees & Binary Search TreesVerified

GATE CSE 2025 PYQ: Suppose the values 10 , − 4 , 15 , 30 , 20 , 5 , 60 , 19 10,-4,15,30,20,5,60,19 10 , − 4 , 15 , 30 , 20 , 5…

Suppose the values 10,−4,15,30,20,5,60,1910,-4,15,30,20,5,60,19 are inserted in that order into an initially empty binary search tree. Let TT be the resulting binary search tree. The number of edges in the path from the node containing 19 to the root node of TT is _________. (Answer in integer)

    Answer

    4

    Approach

    Build the binary search tree by inserting the given values in the stated order, then count the edges on the unique path from the node containing 19 up to the root.

    Node 19 is at depth 4 in the resulting BST, so the number of edges from 19 to the root is 4.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.