Algorithmic Toolbox week3 Greedy Algorithm

Largest Numbers

By the end, you will be able to describe how greedy algorithms work in general and define what is a safe move and a subproblem.

Car Fueling

image.png
Greedy Strategy
Greedy Choice

For example, you can always refill at the closest gas station to you.

Another way is to refill at the farthest reachable gas station, and by reachable, I mean that you can get from your current position to this gas station without refills.

Another way is, for example, to go until there is no fuel and then just hope that there will be a gas station in there.

We go from A to the farthest reachable gas station G so that we can get from A to G with full tank without any refills in the middle.

Greedy Algorithm

And by definition, a subproblem is a similar problem of smaller size.

Another important term is safe move. We call a greedy choice a safe move if it is consistent with some optimal solution.

In other words, if there exists some optimal solution in which first move is this greedy choice, then this greedy choice is called a safe move.

Proof

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容