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!Most modern compilers are able to optimize recursive algorithms into iterative ones, which is why it is generally better to implement the algorithm in a method that is easily readable. Many of the ugly performance hacks are now done by the compilers making them useless to put into the code itself.
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.
Matt Liotta President & CEO Montara Software, Inc. http://www.MontaraSoftware.com (888) 408-0900 x901
----------------------------------------------------------
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]