OA. free
Free
Micron Computer Science Algorithms & Data Structures Medium

A sequence of integer keys is inserted one by one into an initially empty Binary Search...

Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.

A sequence of integer keys is inserted one by one into an initially empty Binary Search Tree (BST): 23, 16, 17, 20, 15, 76. Which key becomes the immediate right child of the root node?

Choose one option.
Show answer & explanation
Answer: B. 76

In a BST, the first inserted key (23) becomes the root. Subsequent keys are placed based on BST property: values less than parent go left, values greater go right. The immediate right child of root 23 is the first key inserted that is greater than 23. Among the sequence, only 76 is greater than 23, so 76 becomes the right child of root.

Step-by-step Derivation:
Step-by-step BST construction:

  1. Insert 23 → Root node (empty tree)
  2. Insert 16 → 16 < 23, goes LEFT of 23
  3. Insert 17 → 17 < 23, go left; 17 > 16, goes RIGHT of 16
  4. Insert 20 → 20 < 23, go left; 20 > 16, go right; 20 > 17, goes RIGHT of 17
  5. Insert 15 → 15 < 23, go left; 15 < 16, goes LEFT of 16
  6. Insert 76 → 76 > 23, goes RIGHT of 23 (root's right child)

Final tree structure:

        23 (root)
       /  \
      16   76 ← immediate right child of root
     / \
    15  17
         \
          20

The immediate right child of root 23 is 76.