VOOZH about

URL: https://www.geeksforgeeks.org/dsa/print-full-nodes-binary-tree/

⇱ Print all full nodes in a Binary Tree - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Print all full nodes in a Binary Tree

Last Updated : 23 Jul, 2025

Given a binary tree, print all nodes will are full nodes. Full Nodes are nodes which has both left and right children as non-empty.

Examples: 

Input : 10
 / \
 8 2
 / \ /
 3 5 7
Output : 10 8

Input : 1
 / \
 2 3
 / \
 4 6 
Output : 1 3

This is a simple problem. We do any of the traĀ­verĀ­sals (Inorder, PreĀ­order, PosĀ­torder, level order traversal) and keep printing nodes that have mode left and right children as non-NULL.

Implementation:


Output
1 3 

Time Complexity : O(n)
Space complexity: O(n) for Recursive Stack Space in case of Skewed Tree

Comment
Article Tags:
Article Tags: