In Greedy approach consider greedy choice property, we can make whatever choice seems best at the moment and then solve the sub-problems that arise later. The choice made by a greedy algorithm may depend on choices made so far but not on future choices or all the solutions to the sub-problem. It iteratively makes one greedy choice after another, reducing each given problem into a smaller one. **In other words, a greedy algorithm never reconsiders its choices. This is the main difference from dynamic programming,** **which is exhaustive and is guaranteed to find the solution**. After every stage, dynamic programming makes decisions based on all the decisions made in the previous stage, and may reconsider the previous stage’s algorithmic path to solution. For example, let’s say that you have to get from point A to point B as fast as possible, in a given city, during rush hour. A dynamic programming algorithm will look into the entire traffic report, looking into all possible combinations of roads you might take, and will only then tell you which way is the fastest. Of course, you might have to wait for a while until the algorithm finishes, and only then can you start driving. The path you will take will be the fastest one (assuming that nothing changed in the external environment). On the other hand, a greedy algorithm will start you driving immediately and will pick the road that looks the fastest at every intersection. As you can imagine, this strategy might not lead to the fastest arrival time, since you might take some “easy” streets and then find yourself hopelessly stuck in a traffic jam.

In mathematical optimization, greedy algorithms solve combinatorial problems having the properties of matroids. For Dynamic programming :It is applicable to problems exhibiting the properties of overlapping subproblems and optimal substructure

## 1 Comment

## Anshul Saxena

May 1, 2016 at 9:45 PMNice.

.