Lecture -18 Dynamic Programming
Why Stack Overflow recommends it
Stack Overflow users link it as a lecture-style introduction to dynamic programming, especially when asking or answering questions about the knapsack problem.
Recommended by 2 people across 2 different months, 2010 to 2016.
What it is
A 52-minute lecture on dynamic programming from the IIT Bombay Design and Analysis of Algorithms series, taught by Prof. Abhiram Ranade and Prof. Sunder Vishwanathan and posted by NPTEL. It works through the DP technique with the knapsack problem as a main example.
What people said
Recommends moinudin · 2010-12 · Stack Overflow · on “Good examples, articles, books for understanding dynamic programming”
This USACO article [LINK] is a good starting point to understand the basics of DP and how it can give tremendous speed-ups. Then look at this TopCoder article [LINK] which also covers the basics, but isn't written that well. This tutorial from CMU is also pretty good. Once you understand that, you will need to take the leap to 2D DP to solve the problem you refer to. Read through this Topcoder article [LINK] up to and including the apples question (labelled intermediate). You might also find watching this MIT video lecture [this video] useful, depending on how well you pick things up from videos. Also be aware that you will need to have a solid grasp of recursion before you will successfully be a
Recommends tome · 2015-04 · Stack Overflow · on “Knapsack - determining set from total value”
After seeing this [this video] lecture I created the following knapsack code. In the lecture, the professor says it will be easy to determine the set from the optimal value (minute 19:00), however I can not find how to do it. I provide an example in the code which sums the values to 21, how can I determine the set (in this case 12, 7, 2) from this value? /* v = value w = weight c = capacity */ function knapsack(v, w, c) { var n = v.length, table = []; // create two-dimensional array to hold values in memory while (table.length <= c) { table.push([]); } return ks(c, 0); function ks(c, i) { if (i >= n) { table[c][i] = 0; return table[c][i]; } if (c < w[i]) { if (table[c][i+1] === undefined) { table
Cites nits.kk · 2016-08 · Stack Overflow · on “How does DP helps if there are no overlapping in sub problems [0/1 knapsack]”
Consider below inputs for typical Knapsack problem. V = [10,8,12] W = [2,3,7] i = 1,2,3 C = 10 I tried recursion with memoization to solve this sample but found no overlapping sub problem. Signature of the recursive procedure : knapsack(int c, int i) Called initially as knapsack(10,1) [LINK] The method of the solution is like as explained in [this video] and [LINK] . How does Dynamic programming helps in reducing the time complexity for such samples of Knapsack ? If it does not help improving the time complexity of this case then does worst case complexity of DP solution also same as of back track search based i.e. 2 to the power n [ ignoring the pruning, as if pruning applied then complexity wil