3

When I'm working on a algorithm problem, I can usually find a top-down solution that works with recursion.

Then for optimization purpose I try to do a bottom-up approach (dynamic programming) to remove the recursion stack, and I struggle. I have a really hard time initializing the array with the correct value, and then fill it with the answers to the sub problems.

Do you have any recommendations / tips on how to "convert" a top-down solution to a bottom-up algorithm?

Thomas
  • 31
  • 1
  • This feels very broad to me. I'm not really sure what an answer would look like, beyond "It's depends completely on what problem you're trying to solve." – David Richerby Jan 26 '18 at 17:25
  • The short answer is "memoization". See https://cs.stackexchange.com/q/2057/755, https://cs.stackexchange.com/q/47216/755, https://cs.stackexchange.com/q/66274/755, then read a textbook and work through a few examples to see how it works. – D.W. Jan 26 '18 at 19:59

0 Answers0