Print All The Full Nodes in a Binary Tree

Objective: Given a binary tree, print all nodes will are full nodes.

Full Nodes: Nodes Which has both the children, left and right are called Full Nodes


quite simple Solution.

  • Do the any of the traversal (inorder, preorder, postorder etc).
  • During traversal, check the node if it has left child and right child, If yes then print it

Complete Code:

public class FullNodes {
public void FindFullNodes(Node root) {
// do the traversal and print all the nodes which has left and right
// child
if (root != null) {
if (root.left != null && root.right != null) {
System.out.print( + " ");
public static void main(String[] args) {
Node root = new Node(1);
root.left = new Node(2);
root.right = new Node(3);
root.left.left = new Node(4);
root.left.right = new Node(5);
root.left.left.right = new Node(8);
FullNodes f = new FullNodes();
System.out.print("Full Nodes are ");
class Node {
int data;
Node left;
Node right;
public Node(int data) { = data;

view raw
hosted with ❤ by GitHub


Full Nodes are 2 1

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.