Usage examples of greedy algorithms?

后端 未结 10 1857
孤城傲影
孤城傲影 2021-02-02 15:36

What is the use of greedy algorithms? An real example?

10条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 16:30

    Some problems are such that a greedy solution will actually be optimal, and sometimes they're engineered that way. A fun example is that many countries' coin values are such that a greedy approach to returning change (i.e. always returning the largest-possible coin until you're done) works.

提交回复
热议问题