Limitations of Top-Down Dynamic Programming
Understand the drawbacks of top-down dynamic programming, including excessive recursion leading to stack overflow and high execution costs. Learn why loops offer better scalability and prepare for the bottom-up approach that avoids these limitations.
We'll cover the following...
Massive amount of recursion
Top-down dynamic programming consists of recursive calls to the subproblems. The answer is not evaluated until all the subproblems have been evaluated; which in turn depends on their own subproblems. We quickly have a huge number of incomplete recursive calls on our program stack. If we keep making these recursive calls and no previous calls have evaluated; we will run out of space on the stack. This will end up in erroneous termination of the program. Run the following code of the Fibonacci numbers algorithm we discussed in the last chapter.
The program will terminate ...