

I first read this OPT formula from the book Algorithm Design(the first pic), I understand this very well I think, whether use i-1 edges or i edges leading to different OPT(i-1,v) or OPT(i-1,w)+Cvw.
However, when I read the same problem from the book Algorithms (the second pic starting from "In dynamic programming..."), I am confused because it eliminates the OPT(i-1,v), which means delete the condition that path P uses at most i-1 edges, and just using OPT(i-1,w)+Cvw. I was just wondering why this formula is still OK? Can someone explain?
I believe that the distinction is in what the DP values mean. In the first case, the value means "the best path to v using at most i edges," and in the second the value means "the best path to v using exactly i edges." Given the second of these you can directly read off the answer by looking at the final DP value, whileas in the second you'd have to look at dp(v, 0), dp(v, 1), dp(v, 2), ... dp(v, n - 1).
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With