Skip to content
Official PYQ · 2015

GATE CS 2015 Set 1 Q10 — Binary Search Trees

Explain with AI

Which of the following is/are correct in order traversal sequence(s) of binary search tree(s)?

  1. 3,5,7,8,15,19,253, 5, 7, 8, 15, 19, 25
  2. 5,8,9,12,10,15,255, 8, 9, 12, 10, 15, 25
  3. 2,7,10,8,14,16,202, 7, 10, 8, 14, 16, 20
  4. 4,6,7,9,18,20,254, 6, 7, 9, 18, 20, 25
Choose one option
View worked solution

Answer: A

A fundamental property of a Binary Search Tree (BST) is that its inorder traversal always yields the keys in a strictly increasing (sorted) order.

Let us analyze the given sequences:

  • I. 3,5,7,8,15,19,253, 5, 7, 8, 15, 19, 25: This sequence is sorted in strictly increasing order. Therefore, it is a valid inorder traversal of a BST.
  • II. 5,8,9,12,10,15,255, 8, 9, 12, 10, 15, 25: This sequence is not sorted because 12>1012 > 10. Therefore, it cannot be an inorder traversal of a BST.
  • III. 2,7,10,8,14,16,202, 7, 10, 8, 14, 16, 20: This sequence is not sorted because 10>810 > 8. Therefore, it cannot be an inorder traversal of a BST.
  • IV. 4,6,7,9,18,20,254, 6, 7, 9, 18, 20, 25: This sequence is sorted in strictly increasing order. Therefore, it is a valid inorder traversal of a BST.

Thus, only sequences I and IV are correct inorder traversal sequences of a BST.

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

Published
Report a correction
Keep exploringMore Binary Search Trees questions