Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

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

The keys 40, 20, 60, 10, 30, 50, 70 are inserted in this order into an empty binary search tree. The root is then deleted, using its inorder successor as the replacement. What is the preorder traversal of the resulting tree?

Trees

Pick an option to check your answer.

The tree is 40 with left subtree 20 (children 10, 30) and right subtree 60 (children 50, 70). Deleting the root 40 replaces it with its inorder successor, the minimum of the right subtree, which is 50; 50 is a leaf, so it is simply removed from its old place. The new tree is 50 with left subtree 20 (10, 30) and right subtree 60 (right child 70). Preorder (root, left, right): 50 20 10 30 60 70.

Why not the others

  • 30 20 10 60 50 70 uses the inorder predecessor (30) instead of the successor.
  • 10 20 30 50 60 70 is the inorder traversal, which is always sorted.
  • 20 10 30 60 50 70 is the original preorder with 40 simply dropped, which is not a valid tree.

Report an error

GATE CS · Data Structures · Trees