Thursday, April 17, 2008

Traverese tree in PostOrder

/*
Given a binary tree, print its
nodes according to the "bottom-up"
postorder traversal.
*/
void printPostorder(struct node* node) {
if (node == NULL) return;
// first recur on both subtrees
printTree(node->left);
printTree(node->right);
// then deal with the node
printf("%d ", node->data);
}

No comments: