This program is computing binomial coefficients by using three different methods:
- Divide-and-conquer
- Dynamic Programming ("bottom-up" approach)
- Memoization (a special form of dynamic programming)
This approach can be used to compute binomial coefficients, but it is very slow due to redundant calculations performed by the recursive calls. The following code snippet is an example of the divide-and-conquer approach:
This type of DP approach is known as the "bottom-up" approach. It is the basic dynamic programming approach. It solves subproblems in order from smallest to largest until the original problem is solved.
This a dynamic programming tecchnique that uses the "top-down" recursive definition to solve only the needed smalller problems and avoids redundant calculations by solving smaller-problems once and storing their solutions. The following code uses memoization to compute Fibonacci numbers: