Question
The following sequence corresponds to the preorder traversal of a binary search tree :
The position of the element in the postorder traversal of is ______. (answer in integer)
Note: The position begins with 1.
Official answer and solution
- Official answer
- 7
- From
- Official GATE 2026 answer key
Solution
Reconstruct the BST from its preorder sequence by partitioning around each root, then write its postorder sequence.
In a BST, the first element of the preorder sequence is the root, all smaller elements form the left subtree, and all larger elements form the right subtree:
- Root
- Left subtree of : ( nodes)
- Right subtree of : with root :
- Left subtree of : (root , right child )
- Right subtree of : (root , left child )
Concatenating gives the full postorder traversal of :
The element is at position 7.
7
Listing 60 before its right child 70 in postorder (which would give position 6).
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
- Question
- 62 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.