For a valid binary tree, an in-order traversal will always result in a strictly non-descending order, so yours is correct.
In a postorder traversal, you visit both your children before you visit yourself. Therefore, yours is wrong right off the bat because 1 must come after 2, since 2 is a child of 1.
Code:
void visit_node(Node * node)
{
if(!node)
return;
visit_node(node->left);
visit_node(node->right);
//do something with node's val, like print it
std::cout << node->val;
}
That's all there is to it. Just follow that down to get your order.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.