Alaina Kafkes
1 min readNov 27, 2017

--

Hi Rashmi! What I mean here is that the decision made at an arbitrary step called i-1 depends on future decisions to run or not run the punchcard. This sounds counterintuitive — after all, humans cannot make decisions based on a future that hasn’t happened yet! However, dynamic programming is different: the initial decision (base case) occurs at either the start (the first punchcard) or the end (the last punchcard). In this problem, I started making decisions from punchcard n (the last punchcard) and worked backwards from there, which implies that the decision about punchcard n-1 depends on the decision made about punchcard n. This is analogous to my statement that the decisions made for punchcards i through n impact whether the algorithm runs punchcard i-1.

--

--