This post is completed by 2 users
|
Add to List |
67. Printing Nodes without Siblings in a Binary Tree
Objective: Given a binary tree, Print All the Nodes that don't have siblings.
Note: The sibling node is the node that has the same parent, so you need to print the node that is a single child of his parent.
Example:
![Print All the Nodes that don't have siblings.](/static/media/algorithms/2014/11/Print-All-the-Nodes-that-dont-have-siblings.1.png)
Approach:
- Do the inorder traversal.
- check if the node has only a child, if yes then print that child.
Output:
Nodes with No Siblings: 6 7 8 9