Recursion is the procedure of solving a problem by breaking it down into a smaller version of itself. It is similar to factorial notation of a nonnegative number in algebra. Below are the equations that define algebraic factorial notation.

Equation 1:0! = 1
Equation 2:n! = n * (n - 1)! If n > 0

These equations can be used to help define the concept of recursion in computer programming. A further explanation of them is needed to better understand how they can help. Equation 1 is known as the base case while equation 2 is known as the general case. Equation 1 contains no factorial notation while equation 2 is a smaller version of itself. These two equations are known as recursive definition. The following can be derived from recursive definition:

1. Every recursive definition must have one (or more) base cases.

2. The general case must eventually be reduced to a base case.

3. The base case stops the recursion. (Malik 357)

Using the information learned from above, a computer programmer can solve a problem by using a recursive algorithm or recursive function. A recursive algorithm has to have one or more base cases as well as the general solution being eventually reduced to a base case. A recursive function contains a statement that calls itself before the current call is completed. Recursive functions are used to implement recursive algorithms. Keep in mind that having a recursive function in a program allows the program to have an unlimited number of copies of that function. Also that every recursive call to a recursive function has its own set of variables and parameters as well as its own code. Finally remember that control goes back to the calling environment after it completes a recursive call. Before control can go back to the previous call, the current recursive call must finish executing. The previous call will resume execution at the point immediately following where the current recursive call has...

...fact ( int n ) { if ( n == 0 ) return 1; return n * fact(n-1); }
// base case // recursive step
Requirements
Must have
Small version of problem solvable without recursion Strategy to simplify problem into 1 or more smaller subproblems Ability to calculate overall solution from solution(s) to subproblem(s)
Making Recursion Work
Designing a correct recursive algorithm Verify
1. Base case is
Recognized correctly Solved correctly 2. Recursive case...

...The Property of Recursion in Birdsong and Human Language
Introduction:
Human speech and birdsong have numerous parallels. Both humans and songbirds learn their complex vocalizations early in life, exhibiting a strong dependence on hearing the adults they will imitate, as well as themselves as they practice, and a waning of this dependence as they mature. Innate predispositions for perceiving and learning the correct sounds exist in both groups, although more evidence of...

4946 Words |
21 Pages

Share this Document

Let your classmates know about this document and more at StudyMode.com

## Share this Document

Let your classmates know about this document and more at StudyMode.com