in DS edited by
14,340 views
4 votes
4 votes

In delete operation of BST, we need inorder successor (or predecessor) of a node when the node to be deleted has both left and right child as non-empty. Which of the following is true about inorder successor needed in delete operation?

  1. Inorder Successor is always a leaf node
  2. Inorder successor is always either a leaf node or a node with empty left child
  3. Inorder successor may be an ancestor of the node
  4. Inorder successor is always either a leaf node or a node with empty right child
in DS edited by
14.3k views

3 Comments

I have confusion in A) and B) Plz explain
0
0
is it B?
0
0
Plz explain by giving suitable example.
0
0

2 Answers

5 votes
5 votes

      option b

Inorder successor is always either a leaf node or a node with empty left child 

3 Comments

thanks a lot.
0
0
Empty left child means i didn't get it plz explain??
0
0
empty left child means no left child of inorder successor
0
0
2 votes
2 votes
Answer =B.

This case of deletion will come when node will have both left and right child.

So in order successor will come from right subtree tree.

In order successor will be left most child from right subtree.

So there can be two cases:-

1. The right subtree root will have left child. In that case we get successor from leftmost child

2. The root of right subtree(of the node to be deleted) has empty left tree. In that case root of right subtree will become the successor.

Related questions