RECURSION.Well, we have activities regarding the recursion. Mr. Balbuena teaches this lesson well, but in our the activity given, we have encountered some difficulties in running our program. God! napaka-hirap talaga 'nun.
Here's some of our discussions:
Recursion is repetitive process by which a function calls itself. It is also termed as the circular.
The Direct Recursion is a recursive functions that can call itself through a function call directly inside the body of the function. While the second type of recursion is the indirect recursion. The
Indirect Recursion is a recursive functions that can call another function outside its function.
For example in this program segment:
Factorial (int n)
{
If (n==1n==0) return 1;
else return (n * factorial (n-1));
}
In this program segment, it illustrates a function containing a call to it. The lines else return (n * factorial (n-1)); contains the function call for the factorial function.
The parts of the recursive function include the Base Case. The base case can be found in the “if clause”. It contains the condition that should be satisfied at one point of execution to terminate the repetitive process done be the recursive function. And the other part of the recursive function is the General Case. The general case can be located on the “else-clause”. It contains the function call of the recursive function to itself.
Most high-level computer programming languages support recursion by allowing a function to call itself within the program text. Imperative languages define looping constructs like “while” and “for” loops that are used to perform repetitive actions. Some functional programming languages do not define any looping constructs but rely solely on recursion to repeatedly call code. Computability theory has proven that these recursive only languages are mathematically equivalent to the imperative languages, meaning they can solve the same kinds of problems even without the typical control structures like “while” and “for”....Ü

No comments:
Post a Comment