![]() ![]() Input: Set of items X, profit P, weight W and knapsack capacity M Description: Solve knapsack problem using dynamic programming ![]() If (p, w) ∉ S n – 1, then set x n = 1, update p = p – x n and w = w – w n Algorithm This will find the solution of KNAPSACK(1, n, M). It also purges all the pairs (p, w) from S i + 1 if w > M, i.e. MERGE_PURGE does following:įor two pairs (p x, w x) ∈ S i + 1 and (p y, w y) ∈ S i + 1, if p x ≤ p y and w x ≥ w y, we say that (p x, w x) is dominated by (p y, w y).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |