This post is completed by 3 users

Add to List 
Tree Traversals
There are multiple ways to in which you can traverse a tree. In this article we will see these traversals in detail. If you are new to trees then I would recommend that you pay close attention to this article because you will be solving almost all the problems on tree by using one or more of these traversals.
Here we will discuss the recursive approach, we will have separate posts for Iterative or Nonrecursive approach.
Traversals:
 Preorder
 Inorder
 Postorder
 Breadth First Search(BFS) or Level order traversals
 Depth First Search(DFS).
In every traversal we visit the tree in certain order. lets discuss them in detail.
Preorder Traversal: ( Read about nonrecursive approach of Preorder Traversal)
 Visit the root.
 Visit the leftsubtree.
 Visit the rightsubtree.
Inorder Traversal: ( Read about nonrecursive approach of Inorder Traversal)
 Visit the leftsubtree.
 Visit the root.
 Visit the rightsubtree.
Postorder Traversal: ( Read about nonrecursive approach of Postorder Traversal)
 Visit the rightsubtree.
 Visit the leftsubtree.
 Visit the root.
Click here to read about BreadthFirst Search and DepthFirst Search.
Code:
Output: Inorder Traversal:4 2 5 1 6 3 7 Preorder Traversal:1 2 4 5 3 6 7 Postorder Traversal:7 6 3 5 4 2 1
Also Read: