GDB cs502
GDB cs502
Dynamic programming
i) Decompose problem into sub-problems like divide and conquer
ii) Sub-problems are dependent
iii) Record results of smaller sub-problems
iv) Re-use it for further occurrence
v) Mostly reduces complexity exponential to polynomial.
In contrast of dynamic programming and greedy approach, the i prefer for the solution of 0/1
knapsack problem is dynamic programming.
Reason behind this Algorithm:
In 0-1 Knapsack, items cannot be broken which means the thief should take the item as a whole
or should leave it.
0-1 Knapsack cannot be solved by Greedy approach. it does not ensure an optimal solution.
I also know that the greedy algorithm works for fractional knapsack problem because the
globally optimal choice is to take the item with the largest value. The greedy algorithm only
works because we can “cut up” items to fill the rest of the knapsack, we cannot do that in the 0–
1 case.
The DM programing is guaranteed that Dynamic Programming will generate an optimal solution
using Principle of Optimality.
Dynamic programming is more efficient than Greedy. Greedy algorithm have a local choice of
the sub-problems whereas Dynamic programming would solve the all sub-problems and then
select one that would lead to an optimal solution.