Looks great, bookmarked. A big problem with explaining/learning this area is the name. Names are important but unfortunately the name "dynamic programming" is, according to the people responsible for choosing the name, just BS that they made up one day for their employer.
> unfortunately the name "dynamic programming" is, according to the people responsible for choosing the name, just BS that they made up one day for their employer. For people interested, Richard Bellman who apparently came up with the name, put down the story in his autobiography which is cited on wikipedia: https://en.wikipedia.org/wiki/Dynamic_programming#History "I spent the Fall quarter (of 1950) at RAND. My firs…
Dynamic Programming vs. Divide-and-Conquer (2018)
71–80 of 120 posts
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#72A good history about how bellman came up with this name https://en.wikipedia.org/wiki/Dynamic_programming#History
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#73i'm late to the comments but hopefully this helps someone: i struggled with DP as much as anyone. i read all of the standard resources (CLRS, vazirani, kleinberg, etc), watch all the youtube videos, did all of the practice problems in the books , and still couldn't solve the kinds that are asked on interviews. i even went as far as emailing kleinberg for help. what made it basically unconsciously fluent for me (i.e.…
brute force recursive solution + @lru_cache annotation. works for me every time on leetcode.
I know about lru caches.
Yet, I'm not fully understanding what your implying with your comment.
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#74i'm late to the comments but hopefully this helps someone: i struggled with DP as much as anyone. i read all of the standard resources (CLRS, vazirani, kleinberg, etc), watch all the youtube videos, did all of the practice problems in the books , and still couldn't solve the kinds that are asked on interviews. i even went as far as emailing kleinberg for help. what made it basically unconsciously fluent for me (i.e.…
DP and Greedy problems are the hardest to nail because they are the broadest and widest category of problems. Almost everything can be a DP problem.
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#75Earlier quoted context omitted.
brute force recursive solution + @lru_cache annotation. works for me every time on leetcode.
I've solved some DP problems (I call it: "find the right table/array and then decide whether you feel recursive or iterative"). I know about lru caches. Yet, I'm not fully understanding what your implying with your comment.
Its not a fascinating insight. If you can express a problem as a recursive brute force solution and there's a least a little recalculation involved, you're one step from DP. The lru_cache just does that step.
Just google lru_cache
edit: "op"
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#76Earlier quoted context omitted.
brute force recursive solution + @lru_cache annotation. works for me every time on leetcode.
I've solved some DP problems (I call it: "find the right table/array and then decide whether you feel recursive or iterative"). I know about lru caches. Yet, I'm not fully understanding what your implying with your comment.
you just do:
from functools import lru_cache
@lru_cache(maxsize=None)
def brute_recursive_func(x):
...
And you're good to go.Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#77i'm late to the comments but hopefully this helps someone: i struggled with DP as much as anyone. i read all of the standard resources (CLRS, vazirani, kleinberg, etc), watch all the youtube videos, did all of the practice problems in the books , and still couldn't solve the kinds that are asked on interviews. i even went as far as emailing kleinberg for help. what made it basically unconsciously fluent for me (i.e.…
Another approach is trying to find a "starting point" and solving subproblems. Imagine an array of problems and starting at the left.
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#78Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#79i'm late to the comments but hopefully this helps someone: i struggled with DP as much as anyone. i read all of the standard resources (CLRS, vazirani, kleinberg, etc), watch all the youtube videos, did all of the practice problems in the books , and still couldn't solve the kinds that are asked on interviews. i even went as far as emailing kleinberg for help. what made it basically unconsciously fluent for me (i.e.…
brute force recursive solution + @lru_cache annotation. works for me every time on leetcode.
1) on interviews they want you to explicitly construct the array very often i.e. it's the different between hire and a strong hire exactly because @lru_cache is much easier
2) you can easily blow the stack for real production grade implementations using recursion (think edit distance for genome sequences). you also lose time actually doing the recursion. on the other hand, it's easier to prune the search space with explicit recursion vs tabulation.
edit: btw i'll also say that dynamic programming proper, i.e. as a technique for solving optimization problems defined by recurrence relations, uses tables and recursion (fixed points). so good luck understanding something like the linear quadratic regulator if you think it's just @lru_cache
https://berkeley-me233.github.io/static/ME233_Sp16_L1_DP_Opt...
Re: Dynamic Programming vs. Divide-and-Conquer (2018)
#80i'm late to the comments but hopefully this helps someone: i struggled with DP as much as anyone. i read all of the standard resources (CLRS, vazirani, kleinberg, etc), watch all the youtube videos, did all of the practice problems in the books , and still couldn't solve the kinds that are asked on interviews. i even went as far as emailing kleinberg for help. what made it basically unconsciously fluent for me (i.e.…
DP is basically brute-force but you can reuse some of the subproblems. Another approach is trying to find a "starting point" and solving subproblems. Imagine an array of problems and starting at the left.
this is like saying
"integration is basically weighing a bunch of buckets but the buckets are really small"
cool but that won't help you find the correct trig sub to perform the integral. anyone that's familiar with the calc grind knows getting a good grade for the anti-derivative (indefinite integral) module is about the number of exercises you've done rather than the conceptual understanding.