Difference between revisions of "Recursion"
Jump to navigation
Jump to search
(Undo revision 749963 by TrueClarity (Talk)) |
|||
| Line 1: | Line 1: | ||
| − | + | [http://conservapedia.com/Recursion Recursion]<ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref><ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref><ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref><ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref><ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref><ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref><ref>[http://conservapedia.com/Recursion See http://conservapedia.com/Recursion]</ref> is a technique whereby a [[function]], in order to accomplish a task, calls [http://conservapedia.com/Recursion itself] to accomplish part of the task. [http://conservapedia.com/Recursion Recursion] is notable for having the word "[http://conservapedia.com/Recursion recursion]" in itself. | |
Every recursive solution involves two major parts or cases, the second part having three components: | Every recursive solution involves two major parts or cases, the second part having three components: | ||
| Line 6: | Line 6: | ||
* recursive case(s). A recursive case has three components: | * recursive case(s). A recursive case has three components: | ||
::1. divide the problem into one or more simpler or smaller parts of the problem, | ::1. divide the problem into one or more simpler or smaller parts of the problem, | ||
| − | ::2. call the function (recursively) on each part, and | + | ::2. call the function [http://conservapedia.com/Recursion (recursively)] on each part, and |
::3. combine the solutions of the parts into a solution for the problem. | ::3. combine the solutions of the parts into a solution for the problem. | ||
| + | ::4. If that fails, [http://conservapedia.com/Recursion this] article provides more information on [http://conservapedia.com/Recursion recursion] | ||
These exercises are useful to see examples of recursion: | These exercises are useful to see examples of recursion: | ||
| Line 14: | Line 15: | ||
:2. Write a function to compute 2 to the power of a non-negative integer. | :2. Write a function to compute 2 to the power of a non-negative integer. | ||
:3. Write a function to compute any number to the power of a non-negative integer. | :3. Write a function to compute any number to the power of a non-negative integer. | ||
| + | :4. Write an article about [http://conservapedia.com/Recursion recursion]; attempt to reference the article in itself as many times as possible <ref> Like I'm doing now, also see http://conservapedia.com/Recursion</ref> | ||
| + | |||
| + | If you still don't understand, see [http://conservapedia.com/Recursion recursion] | ||
[[Category:Computer Science]] | [[Category:Computer Science]] | ||
| + | |||
| + | |||
| + | ===References=== | ||
| + | <references/> | ||
Revision as of 23:27, August 12, 2011
Recursion[1][2][3][4][5][6][7] is a technique whereby a function, in order to accomplish a task, calls itself to accomplish part of the task. Recursion is notable for having the word "recursion" in itself.
Every recursive solution involves two major parts or cases, the second part having three components:
- base case(s), in which the problem is simple enough to be solved directly, and
- recursive case(s). A recursive case has three components:
- 1. divide the problem into one or more simpler or smaller parts of the problem,
- 2. call the function (recursively) on each part, and
- 3. combine the solutions of the parts into a solution for the problem.
- 4. If that fails, this article provides more information on recursion
These exercises are useful to see examples of recursion:
- 1. Write a function to compute the sum of all numbers from 1 to n.
- 2. Write a function to compute 2 to the power of a non-negative integer.
- 3. Write a function to compute any number to the power of a non-negative integer.
- 4. Write an article about recursion; attempt to reference the article in itself as many times as possible [8]
If you still don't understand, see recursion
References
- ↑ See http://conservapedia.com/Recursion
- ↑ See http://conservapedia.com/Recursion
- ↑ See http://conservapedia.com/Recursion
- ↑ See http://conservapedia.com/Recursion
- ↑ See http://conservapedia.com/Recursion
- ↑ See http://conservapedia.com/Recursion
- ↑ See http://conservapedia.com/Recursion
- ↑ Like I'm doing now, also see http://conservapedia.com/Recursion