1,239 views

What is the in-order successor of $15$ in the given binary search tree? 1. $18$
2. $6$
3. $17$
4. $20$

$\underline{\textbf{Answer:}\Rightarrow}\;\;\mathbf{c.}$

For finding inorder successor we just need to do the inorder traversal of the given tree.

The element which will come before the given element is called predecessor and the element which will come afterwards is called the successor.

Inorder traversal will be: $\mathbf{2\;3\;4\;6\;7\;9\;13\;\underline{15}\;\enclose{circle}{17}\;18\;20}$
by

Inorder successor of a node is a minimum element in right subtree of that node. Here $15's$ right subtree having $17$  as minimum element which is a inorder successor of $15$.

Morever if we write inorder of the given tree:

2, 3, 4, 6, 7, 9, 13, 15, 17, 18, 20  element after 15 is inorder successor

Option c) is correct

You just need to do the inorder traversal i.e., just sort the elements

2  3  4  6  7  9  13  15  17  18  20.

After 15 17 is coming so answer is c)17

1 vote
1
2,284 views