This post is completed by 2 users

  • 0
Add to List
Beginner

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.

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