Note I've got a 300 word limit.
Using the tree structure from wiki as an example:
http://en.wikipedia.org/wiki/Tree_traversal
Preorder: F B A D C E G I H (Root, L, R)
Inorder: A B C D E F G H I (L, Root, R)
Postorder: A C E D B H I G F (L, R, Root)
Given preoder and inorder list, to generate postorder list:
function postorder (preorder inorder)
1. if there is 1 element in the inorder list, print out and return
2. From preorder, you know the root is the first element of preorder.
3. From preorder, you get the next element is the immediate left child
and the immediate right child from the inorder list.
3. find the new preorder and inorder list for the left child and call
this function recursively.
4. find the new preorder and inorder list for the right child and call
this function recursively.
5. print the first element of preorder.
Example:
Initial call:
Preorder: F B A D C E G I H
Inorder: A B C D E F G H I
1. From preorder, you know the root is F.
2. Given F, from preorder, you get B is the immediate left child (preordering, B is right after F) and get G is the immediate right child from the inorder list (inordering, G is right after F).
3. send the list BADCE as the new preorder and ABCDE as the new inorder to function postorder recursively.
4. Send the list GHI as the new preorder and GIH as the new inorder to function postorder recursively.
5. print F
Note that step 3 is the left child, step 4 is the right child so L, R, Root.
Recursive:
Preorder: BADCE
Inorder: ABCDE
1. From preorder, you know the root is B.
2. Given B, from preorder, you get A is the immediate left child from preorder list and get C is the immediate right child from the inoder list
3. send the list A as preorder and A as inorder and call function postorder recursively
4. send the list DCE as preorder and CDE as inorder recursively call postorder
5. print B
...