Skip to content
GATEiit

GATE CSE 2024 Session 2 Q39: What can be known about a BST from its set of keys alone

Question

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?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: A (official GATE 2024 final answer key)

Concept used: The shape of a BST depends on insertion order, but its inorder traversal is always the sorted order.

First step: Insert the same set in two different orders and compare which traversals change.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2024 Session 2 CS question paper and final answer key, organised by IISc Bangalore. Question paper · Answer key