ISRO 2020 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0104

Consider the following binary search tree. The root is 15, with left child 6 and right child 18. Node 6 has left child 3 and right child 7. Node 3 has left child 2 and right child 4. Node 7 has no left child and has right child 13, whose left child is 9. Node 18 has left child 17 and right child 20.What is the in-order successor of 15 in this binary search tree?
  1. A
    18
  2. B
    6
  3. C
    17
  4. D
    20

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solution\[\boxed{\text{If a node has a right subtree, its in-order successor is the smallest key in that subtree}}\]15 has right subtree rooted at 18. Its smallest key is found by going left from 18 as far as possible: 17.(In-order: 2, 3, 4, 6, 7, 9, 13, 15, 17, 18, 20.)Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com