News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Recursive functions

Started by Danesh, October 07, 2005, 02:22:47 PM

Previous topic - Next topic

Randall Hyde

Quote from: Danesh on October 14, 2005, 01:03:26 PM
Hi Gabor,

I have created a new topic with B-Trees title. I will explain briefly about B-Trees. If you have any idea about implementing B-Tree (Inserting and Deletion) algorithms in non-recursive form, please write there.

Yours,

Danesh



It's not that hard to replace a recursive subroutine with an iterative algorithm. What you can't get away from is the stack. The way many recursive->iterative translations work is to create a stack data structure and maintain that user-defined stack within the code. Of course, if the ultimate goal is to reduce stack usage, this translation is not going to buy you anything (well, it will save you having to push return addresses, but not much more than that unless you're allocating local variables that don't really need a unique copy on each recursive iteration).

Cheers,
Randy Hyde