# Coding Challenge Day-33: Problem 2: Post-Order Traversal of Binary Tree

Hello! So I’m doing a coding challenge where I solve a few questions every day and thought of posting them here on my blog so that you guys can join the challenge too!

Welcome to Coding challenge Day 33: Problem 2! Be sure to post your answers, queries etc in the comments!

Problem : Post-Order Traversal of Binary Tree

Algorithm Logic:

1. Traverse the left subtree, i.e., call Postorder(left-subtree)
2. Traverse the right subtree, i.e., call Postorder(right-subtree)
3. Visit the root.

Solution:

``````package binary_tree;

public class PostOrder_Traversal {

static class Node{

int data;
Node left_child, right_child;

public Node (int d){
data=d;
left_child= right_child=null;
}
}

static class Binary_tree{
Node root;

public void add_left_node (Node parent_node, Node node){
parent_node.left_child=node;
}

public void add_right_node (Node parent_node, Node node){
parent_node.right_child= node;
}

public void postorder_traversal (Node node){
if(node==null)
return;

postorder_traversal(node.left_child);
postorder_traversal(node.right_child);
System.out.print(node.data+ " ");
}
}

public static void main (String [] args){
Binary_tree t= new Binary_tree();

t.root= new Node(10);

Node node11= new Node(20);

Node node12= new Node(30);

Node node111= new Node(40);