The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

recursive -> iterative by dennismv2004-12-21 02:24:43
  Yes, it is _always_ possible. by williamashbless2004-12-21 10:32:48
    I should have finished reading the thread before by Liava 2004-12-21 12:16:27
replying again.

I could have saved myself some typing. You describe it in much more detail than me.

Just to point out one thing. Your "which by some definitions _might_ constitute recursion" is probably redundant, since I'm pretty sure that this would still be recursive by the proper definition.

Consider that recursion is based on the mathematical concept of recursive function definitions, so I could define factorial in two ways. The first is:

f(k) = PI[i = 1 .. k](i)

Which is easily recognizable as the closed-form (iterative) definition.

Alternatively, there is:

f(k) = f(k - 1) * k if k > 0
     = 1 if k = 0

Which is easily recognizable as the recursive definition. It doesn't much matter if I write the second function as a function that calls itself, or one that uses a stack or queue to maintain the factors so far; I'm still using a recursive function.

This is probably just a nitpick, but it's an important distinction, I think, since otherwise, whether you are writing a recursive function or an iterative one can become a property of the language you are using.

[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)