On Jun 18, 9:13 am, november <[email protected]> wrote:
> please explain the algo for iterative inorder postorder and pre-order
> tree traversals using stack.....(no code only algo plzz :) )

Code is algorithm.  What don't you understand?  You can convert any
recursive algorithm to iterative by replacing the recursive call with
instructions that save the current state on a stack along with a flag
that shows where the call is, and finally a goto the start of the
recursive procedure.  At the return for the procedure, you check the
stack to see if it has anything on it. If it does, you restore the
state and use the flag to goto the spot just after the call site.  In
other words, you are doing the same thing as the compiled code for the
recursive call would have.  After you are done, if you want, you can
replace the gotos with equivalent loop structures.


-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to