Dynamic Programming

Joshycsm
2 min readAug 10, 2020
https://dev.to/trekhleb/dynamic-programming-vs-divide-and-conquer-218i

Today, I just want to touch on dynamic programming and memoization. We can use memoization to optimize our problems. With dynamic programming we can identify the solution to specific problems. Can the problem be divided into a subproblem of smaller pieces… where most likely you’re gonna be using recursion?

In this case, you want to evaluate if there are repetitive subproblems or tasks. If there are, you can memoize the subproblems so we don’t constantly recalculate things and use this idea of dynamic programming to make the code much more efficient.

Memoization is a common for dynamic programming problems, which are problems such as the the one described above and known also as a Fibonacci problem. I would do a little research on what Fibonacci means in context by doing a quick google search for this word.

Another way of incorporating dynamic programming is called the bottom up approach. I will not be focusing too much on this right now. It can incorporate the use of a for loop but we will skip this discussion for now.

It can avoid recursion but might not be viewed as being so clean. But there can be disagreements about whether it is cleaner written code or not. In an interview, it would be more rare for you to implement both of the described methods above.

And as always, I highly recommend the Zero to Mastery Academy to improve your own personal skills as a programmer as this is where all this information was drawn from and Andrei Neagoie, the founder and lead instructor, has been a true mentor to me.

Photo credit: https://dev.to/trekhleb/dynamic-programming-vs-divide-and-conquer-218i

--

--