COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Inorder Successor is always a leaf node
|
|
Inorder successor is always either a leaf node or a node with empty left child
|
|
Inorder successor may be an ancestor of the node
|
|
Inorder successor is always either a leaf node or a node with empty right child
|
Detailed explanation-1: -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? Correct answer is option ‘B’.
Detailed explanation-2: -Inorder Successor : In the above BST if we want to remove 5 then first we will find an inorder successor(To get a node which is just greater than the node to be deleted) so the inorder successor is 8 so we replace 5(node to be deleted) with 8(inorder successor) and delete 8.
Detailed explanation-3: -Method-3: Deletion of A Node Having Two Children Nodes In this, the node which is to be deleted is replaced with its in-order successor or predecessor recursively until the node to be deleted is replaced on the leaf of the tree. After this, replace the node with NULL and free the allocated space.
Detailed explanation-4: -As we know that to delete any node in BST we replace that deleted node with its inorder predecessor or successor.
Detailed explanation-5: -Introduction to Binary Tree Deletion. Binary tree deletion is known as the delete a node from the binary tree. Delete a node from a binary tree shrinks the tree from the rightmost bottom. That means if you delete a node from a binary tree, it will be replaced by the rightmost bottom node.