Applying Memoization to Dynamic Programming
Dynamic programming is an algorithmic technique that uses memoization to make the execution of recursive calls highly efficient. By caching and reusing the results of a function call, dynamic programming eliminates repetitive recursive calls to functions. So computations that may have exponential time complexity may execute with linear time complexity, thanks to memoization.
In the previous section, we used memoization to compute the Fibonacci number and saw how the technique greatly reduced the computation time. Let’s apply the Memoize delegate we created to solve a well-known problem in dynamic programming—the rod-cutting problem.
Unlike the Fibonacci number, where there’s one number for a given ...
Get Programming Kotlin now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.