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 20:20

>>5

Let me optimize that for you...


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

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