Greedy Analysis Strategies

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Solo95/article/details/86227670

Greedy Analysis Strategies

  • Greedy algorithm stays ahead.
    Show that after each step of the greedy algorithm, its solution is at least as good as other algorithm’s.
    Ex.Interval scheduling

  • Structural.
    Discover a simple “structural” bound asserting that every possible solution must have a certain value. Then show that your algorithm always achieves this bound.
    Ex.Interval partitioning

  • Exchange argument
    Gradually transform any solution to the one found by the greedy algorithm without hurting its quality.
    Ex.Minimizing lateness

Remark.
Greedy algorithm do not always give an optimal solution but can produce a solution that is guaranteed to be close to optimal.

Basic Elements of Greedy Algorithm

Usually, if the given problem has the following ingredients(hallmark in other teaching material, Steve add this note), then it is more likely to develop a greedy algorithm for it.

  • Greedy-choice property.
    A locally optimal choice is globally optimal。

We can assemble a globally optimal solution by making locally optimal(greedy) choices. That is, when we make the choice that looks best in the current problem, without considering results from subproblems.

  • Optimal substructure.
    A problem exhibits optimal substructure if an optimal solution to the problem contain within it optimal solutions to subproblems.

注意,这里的最优子结构和动态规划的hallmark 1是一样的。事实上,贪心法解决不了的问题,可以尝试使用动态规划来解决。

在这里插入图片描述
0-1背包问题,有最优子结构,但使用贪心法无法解决,需要使用动态规划。

猜你喜欢

转载自blog.csdn.net/Solo95/article/details/86227670
今日推荐