What is the difference between dynamic programming and greedy approach?

前端 未结 6 2384
忘掉有多难
忘掉有多难 2020-12-12 10:10

What is the main difference between dynamic programming and greedy approach in terms of usage?

As far as I understood, the greedy approach sometimes gives a

6条回答
  •  鱼传尺愫
    2020-12-12 10:59

    Difference between greedy method and dynamic programming are given below :

    1. Greedy method never reconsiders its choices whereas Dynamic programming may consider the previous state.

    2. Greedy algorithm is less efficient whereas Dynamic programming is more efficient.

    3. Greedy algorithm have a local choice of the sub-problems whereas Dynamic programming would solve the all sub-problems and then select one that would lead to an optimal solution.

    4. Greedy algorithm take decision in one time whereas Dynamic programming take decision at every stage.

提交回复
热议问题