Wednesday, May 1, 2019

Comparison Between Dynamic Programming and Divide and Conquer.

S.No

Dynamic Programming

Divide and Conquer

1)

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

Divide and Conquer is a method in which solution to a  problem can be obtained by dividing the  problem into several problems ,till it can’t be divided further and can be solved recursively.

2)

A Dynamic Programming algorithm solves every sub-problem just once and saves the results in a table ,from this solutions to the problem  is obtained

In Divide and Conquer ,every sub-problem is solved and the results are combined to get original solution.

3)

Dynamic Programming works best when all sub-problems are dependent , we don’t know where to partition  the problem.

Divide and Conquer works best when all the sub-problems are independent.

4)

Dynamic programming is best suited for solving problems with overlapping sub-problems.

Divide and Conquer is best suited for the case when no overlapping sub-problems are encountered.

5)

Dynamic Programming splits its input at every possible split and after trying all possible splits ,it determines which split point is optional

Divide and Conquer always splits its input at a pre-specified deterministic point(Example, always at middle)

 

No comments:

Post a Comment