Recursion
What is Recursion?
* A problem solving concept which can be used with languages that support the dynamic allocation of memory. * In programming, it is the ability for a function to call itself! * The concept has it's foundation in mathematics.
Advantage/Disadvantage of Recursion
* ADVANTAGE Usually a more concise coding solution, some solutions are more easily implemented using recursion * DISADVANTAGE Less efficient due to overhead involved with function calls.
A Walkthru of Recursive Code
* Run Time Stack * Winding and Unwinding the stack * Local variables, parameters, return values stored on the stack
Two Requirements for Recursive Code
* There must be an anchor point. (Sometimes this is called the base case.) * Each recursive call must approach the anchor point (or base case).