StreakPeaked· Practice

ExamsGATETechnical

Which of the following statement(s) is/are TRUE for any binary search tree (BST) having n distinct integers?

  1. The maximum length of a path from the root node to any other node is (n - 1).
  2. An inorder traversal will always produce a sorted sequence of elements.
  3. Finding an element takes O(log2 n) time in the worst case.
  4. Every BST is also a Min-Heap.

Correct answer: An inorder traversal will always produce a sorted sequence of elements.

Solution

In a binary search tree, the left subtree contains only nodes with values less than the parent node, and the right subtree contains only nodes with values greater than the parent node. Therefore, an inorder traversal, which visits the left subtree, the parent node, and then the right subtree, will always yield the elements in sorted order.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →