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 2006-10-10 5:17

It's really simple: think of how you would implement each traversal using recursion, then substitute a stack with push on entry and pop on exit for each call.

Which is exactly how it's done at machine level (at least without tail recursion removal).

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