Iteration And Recursion Homework Help
Recursion Defined
Recursion is a way of determining information data structures or algorithms in terms of themselves. A recursive algorithm is a form of decomposition where rather than selecting an arbitrary subtask of the issue to do, select a simpler problem that has the same form as the original (self-similarity). A recursive description has two parts:
- The base case - a stopping condition
- The recursive step - an expression of the calculation or definition in terms of itself
Example of a Recursive Definition:
- There are many recursive definitions in mathematics. Consider the factorial function:
- n! = n * (n-1) * (n -2) * … * 2 * 1
- The same function can be defined recursively by giving a base case and a recursive step:
- 0! = 1 (by definition)
- n! = n * (n - 1)! (the recursive step)