• recategorized by
7,960 views
1 1 vote
What is the difference between dynamic programming and divide and conquer technique,

4 Answers

Best answer
9 9 votes
In divide and conquer we divide the larger problem into self similar smaller subproblems and use the answer to the subproblems to find the answer to the larger problem but in doing this we find the answer to each subproblems without checking whether we already computed the answer to that exactly same subproblem earlier. This increases the complexity in problems where all the subproblems are not unique . On the other hand dynamic programming handles this situation very smartly by storing the answers to the subproblems that it computed once. This is also called memoization. This reduces the time complexity in dynamic programming solutions but increases the space complexity.

Another notable difference is that in divide and conquer we recursively solve the larger problem by breaking it into subproblems. The recursion at its maximum depth takes up a lot of memory in the call stack which may sometimes lead to runtime error if the call stack space is exhausted. But in dynamic programming we can take separate dynamically allocated arrays to store solutions of subproblems and use it later to find solutions for larger problems.
• selected by
3 3 votes
In Dynamic programming, we take a problem in which the solutions of subproblems are overlapping, so we divide our main problem into many subproblems and store their solution into tabular form so that we wont need to calculate them again. By solving all subproblems we get the solution of our main problem.

In Greedy programming we don't have any overlapping solutions for any subproblems, we divide the main problem into small sub problems and solve them in greedy way ( what is best for now ), then we combine the solutions to get the final solution.
3 3 votes

In divide and conquer we divide a given problem into sub problems(n number) and solve the subproblems. We may solve all the sub problems completely and combine the result as in the case of merge sort, or we may divide and solve only some  like binary search.

In dynamic programming a problem is divided into sub problems and we store the solution of each sub problems. So whenever the same subproblem occurs the result can be looked up. eg matrix chain multiplication.

0 0 votes

DAC

In Divide and conq we divide the big problem into smaller problems until termination or we can say recursively until termination condition. In this technique we do not check all the possibilities, this is why it may or may not give the correct answer everytime.

Dynamic Programing

In dynamic programing we check all the possibilities(it is all most brutforce). We only calculate the value of distinct function calls and stores the value of that function calls into a table, this is why it is slow at start, after calculating all the distinct function calls dynamic programming is very fast as it just has to took the stored value from the table and puts its value rather then solving the same problem again.

Dynamic programming is useful when we have repeated function calls and worst when we have distinct function calls.

The best example to understand this concept is Fibonacci series  in DAC time complexity  is 2^n but in Dynamic programing it is  o(N) because of repeated function calls.

Position:
Show:

Related questions

2 2 votes
2 answers 2 answers
1.3k
1.3k views
Manasi Srivastava asked Oct 9, 2017
1,317 views
Do we need to study the Strassens's algorithm in detail like proof or working of that algorithm or we just need to know the time complexity of the algorithm because I can...
0 0 votes
1 answers 1 answer
1.1k
1.1k views
0 0 votes
2 2 answers
1.5k
1.5k views
ajit asked Sep 7, 2015
1,453 views
suppose you are given n bit integers asuming for common sense n as power of 2 .it is required to multiply them using divide and conquer method .what is the divide and con...
5 5 votes
1 1 answer
210
210 views
GO Classes asked Aug 5
210 views
Suppose $n$ elements are divided into groups of $r$ elements. The median of each group is found, and the median of these group medians is used as the selection pivot.For ...