Saturday, January 10, 2009

Learnings (lorebeth)

January 10,2009

We had discussed about recursion, even though it is hard to understand but still I'm trying my best.


Recursion defined

The repetitive process by which a functions calls itself is called recursion or circular definition.
This is a way of defining something in terms of itself.
A function is said to be recursive if a statement in the body of the function calls the function that contains it.


Parts of the Recursive function

Base Case
This is the part of the recursive function that is found on the if clause. This contains the condition that should be satisfied at one point of execution to terminate the repetitive process done by the recursive function.

General Case
This is the part of the recursive function that is found on the else-clause. This contains the function call of the recursive function to itself.


Recursion in computer science is a way of thinking about and solving problems. It is, in fact, one of the central ideas of computer science. [1] Solving a problem using recursion means the solution depends on solutions to smaller instances of the same problem. [2]

"The power of recursion evidently lies in the possibility of defining an infinite set of objects by a finite statement. In the same manner, an infinite number of computations can be described by a finite recursive program, even if this program contains no explicit repetitions." [3]

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: