Category:Recursion: Difference between revisions

Content added Content deleted
m (Added TR link)
m (Just a little fiddling)
Line 10: Line 10:
More than one end condition is allowed. More than one recursion condition is allowed.
More than one end condition is allowed. More than one recursion condition is allowed.


Many recursion problems can be solved with an iterative method, or using a [[loop]] of some sort (usually recursion and iteration are contrasted in programming, even though recursion is a specific type of iteration). In some languages, the factorial example is best done with a loop because of function call overhead. Some other languages, like [[Scheme]], are designed to favor recursion over explicit looping, using [[tail recursion]] optimization to convert recursive calls into loop structures. If loop structures are not available (or not allowed) in your language, recursion is a good way to go.
Many recursion problems can be solved with an iterative method, or using a [[loop]] of some sort (usually recursion and iteration are contrasted in programming, even though recursion is a specific type of iteration). In some languages, the factorial example is best done with a loop because of function call overhead. Some other languages, like [[Scheme]], are designed to favor recursion over explicit looping, using [[tail recursion]] optimization to convert recursive calls into loop structures. If loop structures are not available in your language (or not allowed by the rules of your task), recursion is a good way to go.


Below is a list of examples of recursion in computing.
Below is a list of examples of recursion in computing.