Greedy algorithms: greed is good? Greedy algorithms Shortest paths in weighted graphs Greed, for lack of a better word, is good. Greed is right. Greed works. Greed clari fi es, cuts Tyler Moore through, and captures, the essence of the evolutionary spirit. CSE 3353, SMU, Dallas, TX Greed, in all of its forms; greed for life, for money, for love, Lecture 13 knowledge, has marked the upward surge of mankind and greed, you mark my words, will not only save Teldar Paper, but Some slides created by or adapted from Dr. Kevin Wayne. For more information see that other malfunctioning http://www.cs.princeton.edu/~wayne/kleinberg-tardos . Some code reused from Python Algorithms by Magnus Lie corporation called the U.S.A. Hetland. 2 / 50 Greedy algorithms ������������� Goal. Given currency denominations: 1, 5, 10, 25, 100, devise a method to pay amount to customer using fewest number of coins. A greedy algorithm builds a solution incrementally, making the best local decision to construct a global solution Ex. 34¢. The clever thing about greedy algorithms is that they fi nd ways to consider only a portion of the solution space at each step We’ve already seen two greedy algorithms Gale-Shapley algorithm to solve stable-matching problem: men propose 1 Cashier's algorithm. At each iteration, add coin of the largest value that to their best choice, women accept/decline without considering other does not take us past the amount to be paid. prospective o ff ers Earliest- fi nish algorithm to solve interval-scheduling problem: choose 2 the job that fi nishes fi rst and doesn’t con fl ict with jobs already Ex. $2.89. accepted 3 3 / 50 4 / 50
Recommend
More recommend