2 Comments

Very good! The way I like to introduce dynamic programming to my students is to begin with a recursive solution to the problem, and then analyze in the recursion tree what is the dependency structure of problem states, then turning the algorithm upsidedown and starting at the base states. What do you think?

Expand full comment

Yes, that’s how I learnt it too. But I had to learn the hard way that recursive solutions are much slower than iterative ones, and also it’s very hard to get used to the iterative style once you’re used to recursion. I had to make a habit to use iteration in contest problems, so this is coming from my Olympiad background. Recursion is definitely easier to understand, though. I was experimenting with trying to teach this method first to try and get learners used to it rather than eventually finding out what I did. Did I do a good job? And what should I improve on in future articles since DP is a large topic and I’ll write about it again?

Expand full comment