Skip to main content

GATE CSE 2024Data Structures › Trees & Binary Search TreesVerified

GATE CSE 2024 PYQ: ​​​​​​You are given a set V V V of distinct integers. A binary search tree T T T is created by inserting all…

​​​​​​You are given a set VV of distinct integers. A binary search tree TT is created by inserting all elements of VV one by one, starting with an empty tree. The tree TT follows the convention that, at each node, all values stored in the left subtree of the node are smaller than the value stored at the node. You are not aware of the sequence in which these values were inserted into TT, and you do not have access to TT.

Which one of the following statements is TRUE?

  1. A
    Inorder traversal of TT can be determined from VV
    Correct answer
  2. B
    Root node of TT can be determined from VV
  3. C
    Preorder traversal of TT can be determined from VV
  4. D
    Postorder traversal of TT can be determined from VV

Answer

(A) Inorder traversal of T T T can be determined from V V V

Approach

Use the defining property of a binary search tree: its inorder traversal is always the sorted order of its keys. Thus, although the insertion order is unknown, the set $V$ still uniquely determines the inorder traversal. Root, preorder, and postorder depend on the insertion sequence, so they cannot be determined from $V$ alone.

The only traversal determined solely by the set of keys in a BST is the inorder traversal, because it always lists the keys in sorted order. The root, preorder, and postorder all require knowledge of the insertion sequence.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.