Hacker News new | ask | show | jobs
by jefferickson 2725 days ago
Forget about efficiency for the moment and focus on discovering the underlying recursive problem.

LOTS of people struggle with dynamic programming. But in my experience, 90% of the difficulty with dynamic programming is actually discomfort with recursion, which is why I talk about recursive backtracking first.

Try reading Chapter 2. My goal in that chapter is to show the process of deriving recursive solutions---how to think about the problem, and what questions to ask---rather than just presenting the solution as a fait accompli.

I do have to assume that you believe in the Recursion Fairy, though. That's probably the hardest step. Computer scientists are TERRIBLE at delegating.

2 comments

> Recursion Fairy

I mentioned this elsewhere but figured I'd bring it up here since you're the author.

I've tried explaining recursion in a lot of ways like this, such as "just assume it will work", "trust yourself", and "turn off your brain". (The first two are paraphrases from Matthew Flatt, the latter is from Will Byrd.)

I think "Recursion Fairy" is my favorite way to phrase the same idea. I think there's something about the nature of invoking a sense of magic in the phrasing that might help people really believe that it's okay to just let the recursion do its thing and not think about it too much. I'll definitely be using "Recursion Fairy" when (if) I end up explaining recursion again.

Thanks for making your material available for free! Cheers!

i don't have a problem with recursion per se - certainly things like tree traversals (e.g. minimax) are very very obvious to me and for example just a couple of days ago i was thinking about AD for recursively defined functions - but optimal substructure (what i think CLRS calls overlapping subproblems) is what i have trouble with. anyway thank you writing the book - i look forward to reading it and getting yet another perspective.