Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Data Structures
  • BST
  • Medium

The keys 50,30,70,20,40,60,8050, 30, 70, 20, 40, 60, 80 are inserted in this order into an empty binary search tree. What is the postorder traversal?

Trees

Pick an option to check your answer.

The insertions build a perfectly balanced tree: root 5050; left child 3030 (children 2020, 4040); right child 7070 (children 6060, 8080).

Postorder = left subtree, right subtree, root:

  1. Left subtree of 5050: 20,40,3020, 40, 30
  2. Right subtree of 5050: 60,80,7060, 80, 70
  3. Root: 5050

Result: 20,40,30,60,80,70,5020, 40, 30, 60, 80, 70, 50.

Why not the others

  • 20,30,40,50,60,70,8020, 30, 40, 50, 60, 70, 80 is the inorder traversal (always sorted for a BST).
  • 50,30,20,40,70,60,8050, 30, 20, 40, 70, 60, 80 is the preorder traversal.
  • 20,40,60,80,30,70,5020, 40, 60, 80, 30, 70, 50 lists all leaves first, which is not a standard traversal.

Report an error

GATE CS · Data Structures · Trees