The process of generating a sequence (or pattern) from a given first term by applying a rule to obtain any succeeding term from the preceding term (Lesson 1 2)
The facility of a programming language to be able to call functions from within themselves
a reduction of a problem to another (typically smaller) instance of the same problem
Recursion results from a method being invoked when an existing call to the same method has not yet returned For instance public static void countDown(int n){ if(n >= 0){ System out println(n); countDown(n-1); } // else - base case End of recursion } See direct recursion, indirect recursion and mutual recursion for the different forms this can take
The use of recursive definitions to accomplish real things Contrast just going around in circles
The act of defining an object (usually a function) in terms of that object itself
A programming algorithm where a function either directly or indirectly calls itself
A function that calls a simpler version of itself to arrive at a solution For example, the factorial function (n!) can be defined recursively as (n(n-1)!), where (0!) is defined as equal to1 If a function calls another function that calls back the original function again, it is called mutual recursion; most ray-tracing programs fall into this general category
Pertains to a subroutine or function that directly or indirectly references itself
the result of a program or command running a new version of itself If done carelessly this can cause a never-ending loop However as a programming technique it is often used to simplify such tasks as searching down through a directory tree
When a function calls itself, either directly or indirectly If this isn't clear, refer to the entry for "recursion"
Recursion occurs when a piece of code is executed before a previous execution of the same code has terminated; for example, when a program calls itself Code that is capable of being executed in this way is called re-entrant; its instructions must be invariable, and it must define its variables in local-storage so that data from one instance of the code does not interfere with data from another instantiation Recursion is common when using shared library routines, such as in object-oriented programming, API programming, and when packaging code in dynamic link libraries