On Dec 1, 2003, at 1:47 PM, Patrick Branley wrote:
This is a very good point. Anything that can be done with recursion can also
be done using a loop.

Sometimes implementing an algorithm with a loop makes for horrendous code whereas recursive code can be elegant and simple - consider algorithms for processing tree-structured data!


Does anybody know if there is a performance increase ? I would assume there
isnt.

It depends. Recursion relies on function calls which can be expensive (creating a stack frame, pushing variables etc). If the algorithm is sufficiently complex, the extra work you have to do to manage 'context' for a loop may exceed the function call overhead.


Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to