 # Pre Order and Post order traversal

#1

Given a binary tree, how would you find its preorder and postorder traversals. Explain the basic difference between the two traversals.

#2

preorder mince in binary tree is root left right.
that mince we are traversal first root and left than right .
postorder mince in binary tree is left right root.
in postorder we first traversal left and right than root.

#3

Pre Order
As the term suggests ,pre means ‘before’, here in pre -order the root node will be ‘BEFORE’/‘PRE’ the Child nodes. So, considering any node of a binary tree the order is (Root Node ,Left Child node, Right Child node), where the Root node is the node which is taken into concern.

Post Order
As the term suggests ,post means ‘after’, here in post -order the root node will be ‘AFTER’/‘POST’ the Child nodes. So, considering any node of a binary tree the order is (Left Child node, Right Child node, Root node), where the Root node is the node which is taken into concern.

#4

Steps to write traversal of any order(in, post ,pre)
Step 1 :- Seek and find the ‘Second Last’ level of the binary tree

Step 2 :- Using the rule of writing an order (i.e. left ,root,right for in-order etc.) write down the traversal of the nodes of the second last level using the leaf nodes as child nodes. Remember to leave some decent space in between the leaf nodes while writing.

Step 3:- Now consider the written traversals (i.e. the subtrees) as seperate nodes, write down the traversal of the nodes of the third last level using the subtrees as child nodes.

Step 4:- continue the above steps till the root of the tree is achieved.