Thursday, May 2, 2019

Comparison Between The Dynamic Programming and The greedy Method.

S.No

                  Dynamic Programming

                        Greedy Method

1

Dynamic programming is a method in which the solution to a problem can be viewed as a result of the sequence of decisions.

Greedy Method is the most forward technique for constructing solution to an optimum problem through a sequence of steps.

2

In this method more than one decision is made at a time.

In this method ,only one decision is made at a time

3

Dynamic programming considers all the possible sequences in order to obtain the optimum solutions.

Greedy method considers an optimum solution without revising the previous solutions.

4

Principle of optimality holds in the dynamic programming and thus the solutions obtained is guaranteed.

Solutions obtained is not guaranteed

5

Dynamic programming solves the sub-problems bottom up. The problem can’t  be solved completely until we find all the solutions of the sub-problems.

Greedy method solves the sub-problems from the top down. We first need to find  the greedy choice for a problem, then reduce it into smaller one.

6

Dynamic programming is more expensive than greedy , because we have to try every possibility before solving a problem.

Greedy method is comparatively less expensive.

7

In this method we can solve any problem.

There are some problems that greedy cannot solve while dynamic programming can. Therefore , first we try greedy , and then if it fails then we try dynamic programming.

 

1 comment: