Given the following sequence of integers, construct a Binary Search Tree (BST) by inserting the elements in the order given: 50, 30, 70, 20, 40, 60…

Given the following sequence of integers, construct a Binary Search Tree (BST) by inserting the elements in the order given:

50, 30, 70, 20, 40, 60, 80, 35

Draw the resulting BST and determine its inorder, preorder, and postorder traversal sequences.

From the Combined Bank Assistant Programmer (CSE) October 2026 – Written (BIBM) exam, question 14 of 21.

Answers (1)

Building the BST (smaller goes left, larger goes right):

  • 50 → root.
  • 30 < 50 → left of 50. 70 > 50 → right of 50.
  • 20 < 50, < 30 → left of 30. 40 < 50, > 30 → right of 30.
  • 60 > 50, < 70 → left of 70. 80 > 50, > 70 → right of 70.
  • 35 < 50, > 30, < 40 → left of 40.

The resulting tree is in the attached figure (height 3, with 35 the only node on the last level).

Traversals

  • Inorder (Left, Root, Right): 20, 30, 35, 40, 50, 60, 70, 80 — sorted, as always for a BST.
  • Preorder (Root, Left, Right): 50, 30, 20, 40, 35, 70, 60, 80
  • Postorder (Left, Right, Root): 20, 35, 40, 30, 60, 80, 70, 50

— rhs

More from this paper