### What is Microsoft Dynamic Programming?

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".

### Characteristics of Microsoft Dynamic Programming:

Dynamic Programming works when a problem has the following features:-

• Optimal Substructure: If an optimal solution consists of optimal sub solutions then a problem can be stated as optimal substructure.
• Overlapping sub-problems: When a repeated algorithm would visit the same sub-problems frequently, then a problem has overlapping sub-problems.

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.

### Elements of Microsoft Dynamic Programming

There are three basic elements of Microsoft Dynamic Programming algorithm:-

1. Substructure:divide the given problem into smaller sub-problems. Provide the solution of the original problem in terms of the solution for smaller problems.
2. Table Structure:After having the sub-problems, these are stored in a table. This is because sub-problem solutions are repeatedly used over and over again.
3. Bottom-up Computation: Combine the solution of smaller sub-problems to solve larger sub-problems using table, and ultimately arrives at a solution to complete problem.

Note: Bottom-up means:-

• Begin with smallest sub-problems.
• Combining their solutions get the solution to sub-problems of growing size.
• Till solving at the solution of the original problem.

### Components of Microsoft Dynamic programming

1. Stages: Stages is known as the problem which can be divided into multiple sub-problems, stage is a minute portion of a certain problem. For instance, in the shortest path problem, they were explained by the structure of the graph.
2. States:Several states are associated with each stage. Node reached were the states for the shortest path problem.
3. Decision:At every stage, one of the best decisions should be taken out of given several choices. The decision should be optimal taken at every stage; this is what we called a stage decision.
4. Optimal policy: At each stage, it is a rule which determine the decision; a policy is an optimal policy if it is optimal globally. This Bellman principle of optimality.
5. At recent state, the optimal choices for each of the lasting states do not depend on the decisions or previous states. It was not compulsory to know in the shortest path problem, how we got a node only that we did.
6. There is recursive relationship that identifies the optimal decisions for stage j, given that stage j+1, has been solved already.
7. The last stage has to be solved by itself.

### Development of Microsoft Dynamic Programming Algorithm

It can be divided into four steps:

1. Distinguish the structure of an optimal solution.
2. Repeatedly defined the value of the optimal solution. Similar to Divide and Conquer, divide the problem into two or more optimal parts repeatedly. This helps to decide what the solution will look alike.
3. Calculate the value of the optimal solution from the bottom up.
4. Build the optimal solution for the complete problem form the calculated values of smaller sub-problems.

### Applications of Microsoft Dynamic Programming

1. 0/1 knapsack problem
2. Longest common subsequence (LCS)
3. Mathematical optimization problem
4. Flight control and robotics control
5. Time-sharing: It schedules the job to maximize CPU usage
6. All pair Shortest path problem
7. Reliability design problem