+1 vote
in Data Structures & Algorithms I by (110k points)
The following lines talks about deleting a node in a binary tree.(the tree property must not be violated after deletion)

i) from root search for the node to be deleted

ii)

iii) delete the node at

what must be statement ii) and fill up statement iii)

(a) ii)-find random node,replace with node to be deleted. iii)- delete the node

(b) ii)-find node to be deleted. iii)- delete the node at found location

(c) ii)-find deepest node,replace with node to be deleted. iii)- delete a node

(d) ii)-find deepest node,replace with node to be deleted. iii)- delete the deepest node

Enquiry is from Binary Trees using Linked Lists in chapter Binary Trees of Data Structures & Algorithms I

The question was asked during an online interview.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
The correct option is (d) ii)-find deepest node,replace with node to be deleted. iii)- delete the deepest node

Easiest explanation - We just replace a to be deleted node with last leaf node of a tree. this must not be done in case of BST or heaps.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...