Can you explain implementation of deletion from a binary tree?
Submitted by: AdministratorTo implement the deletion from a binary tree, there is a need to consider the possibilities of deleting the nodes. They are:
- Node is a terminal node: In case the node is the left child node of its parent, then the left pointer of its parent is set to NULL. In all other cases, if the node is right child node of its parent, then the right pointer of its parent is set to NULL.
- Node has only one child: In this scenario, the appropriate pointer of its parent is set to child node.
- Node has two children: The predecessor is replaced by the node value, and then the predecessor of the node is deleted.
Submitted by: Administrator
- Node is a terminal node: In case the node is the left child node of its parent, then the left pointer of its parent is set to NULL. In all other cases, if the node is right child node of its parent, then the right pointer of its parent is set to NULL.
- Node has only one child: In this scenario, the appropriate pointer of its parent is set to child node.
- Node has two children: The predecessor is replaced by the node value, and then the predecessor of the node is deleted.
Submitted by: Administrator
Read Online Data Structures Trees Job Interview Questions And Answers
Top Data Structures Trees Questions
☺ | Explain red-black trees? |
☺ | How to find the depth of a binary tree? |
☺ | What is threaded binary tree. Explain its common uses? |
☺ | Do you know implementation of traversal of a binary tree? |
☺ | Explain B+ tree? Explain its uses? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |