Lecture 21: Dynamic Programming III: Parenthesization, Edit Distance, Knapsack
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions on knapsack and edit distance, as a clear walkthrough of the underlying dynamic programming approach.
Recommended by 3 people across 3 different months, 2013 to 2018.
What it is
A 52-minute MIT 6.006 lecture by Erik Demaine that continues dynamic programming with three classic problems: optimal parenthesization, edit distance, and the knapsack problem. It includes the pseudo-polynomial time treatment of knapsack.
What people said
Strong rec jweyrich · 2018-12 · Stack Overflow · on “What is the link between table in knapsack problem and dynamic programming?”
Watch Parenthesization, Edit Distance, Knapsack [this video] by Erik Demaine for the MIT OpenCourseWare. He teaches how to solve Knapsack using Dynamic Programming in pseudo-polynomial time - starting at 43:15. Great lesson!
Recommends max · 2013-10 · Stack Overflow · on “Edit distance recursive algorithm -- Skiena”
Basically, it utilizes the dynamic programming method of solving problems where the solution to the problem is constructed to solutions to subproblems, to avoid recomputation, either bottom-up or top-down. The recursive structure of the problem is as given here [LINK] , where i,j are start (or end) indices in the two strings respectively. Here's an excerpt from this page [LINK] that explains the algorithm well. Problem: Given two strings of size m, n and set of operations replace (R), insert (I) and delete (D) all at equal cost. Find minimum number of edits (operations) required to convert one string into another. Identifying Recursive Methods: What will be sub-problem in this case? Consider
Recommends ioreskovic · 2015-04 · Stack Overflow · on “How to get difference between two lists as transition sequence?”
To post this as an answer instead of as a comment. This looks like Edit distance problem: [LINK] There are already many tutorials/videos for this, but here are some: [this video] [LINK] Happy coding :D
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 [LINK] and [this video] . 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