Skip to content
Official PYQ · 2005

GATE CS 2005 Q33 — Binary Search Trees

Explain with AI

Postorder traversal of a given binary search tree, TT produces the following sequence of keys

10,9,23,22,27,25,15,50,95,60,40,2910, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29

Which one of the following sequences of keys can be the result of an in-order traversal of the tree TT?

Choose one option
View worked solution

Answer: A

A fundamental property of any Binary Search Tree (BST) is that its in-order traversal always yields the keys in strictly ascending (sorted) order.

Let's examine the given options to see which sequence is sorted in ascending order:

  • Option A: 9,10,15,22,23,25,27,29,40,50,60,959, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95 — This sequence is sorted in ascending order.
  • Option B: 9,10,15,22,40,50,60,95,23,25,27,299, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29 — Not sorted (e.g., 2323 appears after 9595).
  • Option C: 29,15,9,10,25,22,23,27,40,60,50,9529, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95 — Not sorted.
  • Option D: 95,50,60,40,27,23,22,25,10,9,15,2995, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29 — Not sorted in ascending order.

Thus, only the sequence in Option A can represent the in-order traversal of the BST TT.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Binary Search Trees questions