Programs that utilize tree structures need to process nodes in a tree (represented as circles in below diagram). Nodes contain information about an object. For now, let's assume each node contains a letter.
Post-order traversal is a type of tree traversal algorithm. Post-order occurs when the root is postponed until its two subtrees are processed.
Given a non-empty tree,
The order would go
D,G,E,B,F,C,A
An example of PostOrder in C++
Steps to post-order traversal
Given a binary tree PY:template
The same example in Haskell might look like
data Tree a = ET | Node(a, Tree a, Tree a)Compare: Pre-order traversal, Inorder traversalpostorder :: Tree a -> [a] postorder ET = [] postorder (Node (x, left,right)) = (postorder left) ++ (postorder right) ++ [x]