Dynamic Programming is the most appropriate design technique for solving optimization problems.
Problem is partitioned into disjoint sub-problems by Divide & Conquer algorithm, solves the sub problems repeatedly and then combines their solution to solve the original problems.
When the sub-problems are not independent Microsoft Dynamic Programming is used, for instance, sharing the same sub-problems. In this situation, divide and conquer is evil necessary, because it solves the same sub problem several times.
Dynamic Programming solves each sub-problem only once and stores the result in a table so that it can be frequently retrieved if required again.
Dynamic Programming is a Bottom-up approach- so we can solve all problems systematically from smaller to bigger problems.
Dynamic Programming is a model of algorithm design in which an optimization problem is solved by the grouping of sub-problem solutions and appearing to the "principle of optimality".
Dynamic Programming works when a problem has the following features:-
When a problem has optimal substructure, then we can repeatedly define an optimal solution. When a problem has overlapping sub-problems, then we can improvise its implementation by computing each sub-problem at one time in a repeated manner.
When a problem doesn't have optimal substructure, there is no focus point for recursive algorithm to have an optimal solutions. When a problem doesn't have overlapping sub problems, we don't have anything to do with dynamic programming.
If the space of sub-problems is enough then dynamic programming can be more efficient than recursion.
There are three basic elements of Microsoft Dynamic Programming algorithm:-
Note: Bottom-up means:-
It can be divided into four steps: