Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Recursive to Iterative algorithms

Name: Anonymous 2006-10-10 4:17

hi. is it possible to write an iterative version of the post-order and in-order binary tree traversal algorithms? I know how to do the one for preorder using stacks, but I can't get my head around the other two.

please help
friend,

Name: Anonymous 2011-06-18 1:25

no. probably doomed for IT aka geek squad. it's obvious from the function name what the order is.

preorder is

int traverse(treeNode *curr) {
    if (curr != NULL) {
        printf("%d", curr->item);
        traverse(curr->left);
        traverse(curr->right);
    }
}


and postorder is moving the curr->item instruction after the recursive calls. simple.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List