in DS edited by
1,239 views
2 votes
2 votes

What is the in-order successor of $15$ in the given binary search tree?

  1. $18$
  2. $6$
  3. $17$
  4. $20$
in DS edited by
by
1.2k views

3 Answers

2 votes
2 votes
$\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}$
edited by
by
0 votes
0 votes

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

0 votes
0 votes

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

Answer:

Related questions