Recursion In Programming
Recursion, in programming, is an algorithm for solving problems that depend on smaller versions of the problem. To solve a large problem, we would first solve a smaller version of the problem and then combine it with something to solve the original problem. We would keep solving smaller versions of the problem until we reach the base case which is the smallest version of the problem. Then we would work backwards combining the outputs and finally solving the original problem. In most programming languages recursion is done by allowing functions to call themselves from inside the function. When writing a recursive function, it is important that we define the correct base case so that our program will eventually terminate. Not having the correct base case, or not having a base case at all, will allow our program to keep making recursive calls, and it will never know to stop. It is also important that we only make recursive calls on smaller and smaller inputs. If our inputs do not ...