Wednesday, August 15, 2012

Print BST "Postorder"


[sourcecode]
/*
 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);
}
[/sourcecode]

No comments:

Post a Comment