ISRO Computer Science (CSE) 2023 - Question 4

All ISRO Computer Science (CSE) papers | ISRO Computer Science (CSE) 2023

Topic: Data Structures

The preorder traversal of a binary search tree is (10, 5, 1, 7, 40, 50). The postorder traversal is

  • A. (1, 5, 7, 10, 40, 50)
  • B. (50, 40, 10, 7, 5, 1)
  • C. (1, 7, 5, 10, 40, 50)
  • D. (1, 5, 7, 50, 40, 10)

Answer: D. (1, 5, 7, 50, 40, 10)

Explanation: From the preorder (Root, Left, Right) of a BST: Root is 10. Elements less than 10 form the left subtree (5, 1, 7) and elements greater form the right subtree (40, 50). Postorder follows Left, Right, Root. Processing recursively, the postorder is (1, 7, 5) for the left subtree and (50, 40) for the right subtree. The overall postorder is 1, 7, 5, 50, 40, 10.

| | All questions of ISRO Computer Science (CSE) 2023