|
Notes > Models of Computation > Recursion
|
Recursion is a prominent feature of many programming languages and it enables an operation to be described in terms of itself with a halt condition that stops the execution of the code if it is satisfied.
The typical example to demonstrate recursion is the factorial function. This function takes a natural number (N), and returns the product of N and all smaller positive integers.
5! = 5*4*3*2*1 = 120
4! = 4*3*2*1 = 24
3! = 3*2*1 = 6
2! = 2*1 = 2
1! = 1
0! = 1
A common method of simplification is to divide a problem into subproblems and in computer programming this is a very important part of designing many important algorithms.
When a recursive function is called, the computer keeps track of the various instances/states of the function. This is typically done by using a stack. Many operations involving tree data structures also use recursion.
Search for "Recursion" on:
Google |
Kelkoo |
Amazon |
eBay (UK) |
eBay (US)
Search for "Recursion" on the rest of Computing Students: Recursion
|
|
|