Skip to content
Official PYQ · 2026

GATE CS 2026 Set 1 Q52 — Searching, Sorting, Hashing

Explain with AI
The following sequence corresponds to the preorder traversal of a binary search tree TT :
50,25,13,40,30,47,75,60,70,80,7750,25,13,40,30,47,75,60,70,80,77
The position of the element 6060 in the postorder traversal of TT is ____\_\_\_\_ . (answer in integer)

Note: The position begins with 11.
View worked solution

Answer: 7 : 7

To find the position of the element 6060 in the postorder traversal, we first reconstruct the Binary Search Tree (BST) from the given preorder traversal: 50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77.

In a BST, the first element of the preorder traversal is the root, elements smaller than the root form the left subtree, and elements larger form the right subtree. Following this recursively, we reconstruct the tree:

  • Root: 5050
    • Left Subtree (elements < 50): Preorder 25, 13, 40, 30, 47
      • Root is 2525. Left child is 1313. Right subtree is 40, 30, 47 (Root 4040, Left 3030, Right 4747).
    • Right Subtree (elements > 50): Preorder 75, 60, 70, 80, 77
      • Root is 7575. Left subtree is 60, 70 (Root 6060, Right 7070). Right subtree is 80, 77 (Root 8080, Left 7777).

Now, we find the postorder traversal (Left→Right→Root\text{Left} \to \text{Right} \to \text{Root}):

  1. Postorder of Left Subtree (rooted at 25): 13,30,47,40,2513, 30, 47, 40, 25
  2. Postorder of Right Subtree (rooted at 75):
    • Left child (rooted at 60): 70,6070, 60
    • Right child (rooted at 80): 77,8077, 80
    • Combined: 70,60,77,80,7570, 60, 77, 80, 75
  3. Postorder of entire tree (rooted at 50):
    13,30,47,40,25,70,60,77,80,75,5013, 30, 47, 40, 25, 70, \mathbf{60}, 77, 80, 75, 50

Counting the positions from left to right (1-indexed):

Position 1 2 3 4 5 6 7 8 9 10 11
Element 13 30 47 40 25 70 60 77 80 75 50

Thus, the position of the element 6060 is 77.

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

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions