edited by
7,511 views

3 Answers

Best answer
8 votes
8 votes

Here root node 24 has children two.After deleting 24 we can replace root element by inorder successor or inorder predecessor of the node. 

             16                                                26

            /    \                                             /

       12        26                                      12

       /   \                                               /    \

    11     13                                          11     16

                                                                  /

                                                              13

     (1)                                                  (2)

 

Either element 16 of left sub-tree or element 26 of right sub-tree will be next root element.

 

Hence,Option(4)16 is the correct choice. 

selected by
2 votes
2 votes

Ans  4 : 16 

Here we must replace 24 with it's Inorder predecessor that is 16 here. 

Logic for Inorder Predecessor:

1) Jump Left to reach 12

2) Descend Right till you encounter a node that does not contain a right child (here 16). That node is your inorder predecessor

Replace the deleted node with inorder predecessor here 16.

0 votes
0 votes

In Binary Search Tree, Inorder Successor of an input node can also be defined as the node with the smallest key greater than the key of input node. So, it is sometimes important to find next node in sorted order.

In the above diagram, inorder successor of is 10, inorder successor of 10 is 12 and inorder successor of 14 is 20.

Answer:

Related questions

3 votes
3 votes
2 answers
1
go_editor asked Aug 16, 2016
3,705 views
Which of the following is not an inherent application of stack?Implementation of recursionEvaluation of a postfix expressionJob schedulingReverse a string
3 votes
3 votes
3 answers
2
go_editor asked Aug 16, 2016
14,121 views
Suppose you are given a binary tree with n nodes, such that each node has exactly eiter zero or two children. The maximum height of the tree will be$\frac{n}{2}-1$$\frac{...
4 votes
4 votes
1 answer
3
7 votes
7 votes
1 answer
4
go_editor asked Aug 14, 2016
5,268 views
A clique in a simple undirected graph is a complete subgraph that is not contained in any larger complete subgraph. How many cliques are there in a graph shown below?2456...