Close
Topic list
Postorder Traversal
EASY
Stacks & Queues
Topics (Covered in this problem)
Problem solved
Skill meter
Stacks & Queues
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Postorder Traversal

Contributed by
Yash Chaudhari
Easy
0/40
Share

## Problem Statement

#### You have been given a Binary Tree of 'N' nodes, where the nodes have integer values. Your task is to find the Post-Order traversal of the given binary tree.

##### For example :
``````For the given binary tree:
``````

``````The Postorder traversal will be [5, 2, 3, 7, 6, 4, 1].
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````2
1 2 3 -1 -1 -1  6 -1 -1
1 2 3 -1 -1 -1 -1
``````
##### Sample Output 1 :
``````2 6 3 1
2 3 1
``````
##### Explanation of Sample Output 1 :
`````` In test case 1, the given binary tree is shown below:
``````

``````Postorder traversal of given tree = [2, 6, 3, 1]

In test case 2, the given binary tree is shown below:
``````

``````Postorder traversal of given tree = [2, 3, 1]
``````
##### Sample Input 2 :
``````2
1 -1 -1
1 2 4 5 3 -1 -1 -1 -1 -1 -1
``````
##### Sample Output 2 :
``````1
5 3 2 4 1
``````
##### Explanation of Sample Output 2 :
``````In test case 1, there is only one node, so Post-Order traversal will be only [1].

In test case 2, the given binary tree is shown below:
``````

``````Postorder traversal of given tree = [5, 3, 2, 4, 1]
``````
Auto
Console