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

QUESTION 20 Consider a binary tree T with 50 nodes as: 1, 2, 3, 4, ....., 26, ....., 50 If...

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

QUESTION 20

Consider a binary tree T with 50 nodes as:

1, 2, 3, 4, ....., 26, ....., 50

If the above values are the nodes of an almost complete binary tree where 1 is the root node, 2 is its left child and 3 is its right child so on, then what is the Parent node, Left Child of node 17?

Choose one option.
Show answer & explanation
Answer: A. Parent: 8, Left Child: 34, Right Child: 35

In a complete binary tree with level-order numbering, for any node n: parent = ⌊n/2⌋, left child = 2n, right child = 2n+1. For node 17: parent = ⌊17/2⌋ = 8, left child = 2×17 = 34, right child = 2×17+1 = 35. All three values are ≤ 50, so all nodes exist.

Step-by-step Derivation:
Using binary tree indexing formulas for a complete binary tree stored in array/level-order form:

  1. Parent of node 17:
    parent(n) = ⌊n/2⌋ = ⌊17/2⌋ = ⌊8.5⌋ = 8

  2. Left child of node 17:
    left_child(n) = 2n = 2×17 = 34
    Check: 34 ≤ 50 ✓ (exists)

  3. Right child of node 17:
    right_child(n) = 2n+1 = 2×17+1 = 35
    Check: 35 ≤ 50 ✓ (exists)

Answer: Parent = 8, Left Child = 34, Right Child = 35