On Mon, 10 Jul 2006, Dylan William Hardison wrote:
> Spake Eben King on Friday, July 07, 2006 at 01:14PM -0400:
>> The prof said any recursive algorithm can be turned into a non-recursive
>> algorithm, which is reasonable, as that's what compiled code with loops
>> completely unrolled is.
>
> This is somewhat misleading.
>
> Any recursive function can be written using iteration, however this does
> not always result in faster code.
Sure, you can make any algorithm worse.
> The problem with recursive functions is not the recursion itself, but
> the stack space used by each call.
True. You have demonstrated a way around this, with tail recursion. I
don't know if it's applicable to every algorithm, but if not, you're no
worse off for trying.
-- -eben QebWenE01R@vTerYizUonI.nOetP royalty.no-ip.org:81 PISCES: Try to avoid any Virgos or Leos with the Ebola virus. You are the Lord of the Dance, no matter what those idiots at work say. -- Weird Al, _Your Horoscope for Today_ ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:37:59 EDT