Properties of recursive algorithms
Learn the fundamental properties of recursive algorithms by exploring how solving smaller instances leads to solving the original problem. Understand the importance of progressively smaller subproblems and hitting base cases through clear examples like factorial calculations.
We'll cover the following...
Here is the basic idea behind recursive algorithms:
To solve a problem, solve a subproblem that is a smaller instance of the same problem, and then use the solution to that smaller instance to solve the original problem.
When computing
In order for a recursive algorithm to work, the smaller subproblems must eventually arrive at the base case. When computing
For example, what if we tried to compute the factorial of a negative number using our recursive method? To compute