Skip to content

Commit 40026dd

Browse files
authored
Update DP3_Parenthesization_EditDistance_Knapsack.java
1 parent 8b656df commit 40026dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

DynamicProgramming/MIT-6.006-IntroToAlgosNotes/DP3_Parenthesization_EditDistance_Knapsack.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ each of the cells in the matrix represents a node in the DAG. The value of the n
8888
The above described approach is the best in terms of time ==> Quadratic in time and space
8989
Better approach ==> Quadratic time and linear space
9090
91+
EDIT DISTANCE CAN BE USED FOR LCS(LEAST COMMON SUBSEQUENCE) AND DNA MUTATION
92+
93+
94+
KNAPSACK PROBLEM
95+
DP Approach -
96+
1. Subproblems - suffix[i:] of items. Each subproblem needs to have 2 kinds of information - item index and remaining capacity.
97+
number of subproblems = theta(nS)
98+
n ==> num of items
99+
S ==> capacity of knapsack
100+
2. Guessing - is item i in knapsack or not? we have 2 choices.
101+
3. Recurrence -
102+
DP(i,X) = max{ DP(i+1,X), DP(i+1,X-Si) + Vi }
103+
Time = theta(nS)
104+
NOT POLYNOMIAL TIME ==> PSUEDOPOLYNOMIAL TIME
91105
*/

0 commit comments

Comments
 (0)