Analog and digital C - Greedy, Study notes of Digital & Analog Electronics

Detail Summery about Greedy Algorithms, Optimization problems, Example: Counting money, A failure of the greedy algorithm, Greedy Vs. Dynamic Programming, Problems.

Typology: Study notes

2010/2011

Uploaded on 09/02/2011

hamit1990
hamit1990 🇮🇳

4.3

(76)

95 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
11
Greedy Algorithms
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Analog and digital C - Greedy and more Study notes Digital & Analog Electronics in PDF only on Docsity!

Greedy Algorithms

Optimization problems

  • (^) An optimization problem is one in which you want to find, not just a solution, but the best solution
  • (^) A “greedy algorithm” sometimes works well for optimization problems
  • (^) A greedy algorithm works in phases. At each phase: - (^) You take the best you can get right now, without regard for future consequences - (^) You hope that by choosing a local optimum at each step, you will end up at a global optimum 2

A failure of the greedy

algorithm

  • (^) In some (fictional) monetary system, “krons” come in 1 kron, 7 kron, and 10 kron coins
  • (^) Using a greedy algorithm to count out 15 krons, you would get - (^) A 10 kron piece - (^) Five 1 kron pieces, for a total of 15 krons - (^) This requires six coins
  • (^) A better solution would be to use two 7 kron pieces and one 1 kron piece - (^) This only requires three coins
  • (^) The greedy algorithm results in a solution, but not in an optimal solution 4

Greedy Vs. Dynamic Programming Greedy choice property

  • (^) We can make whatever choice seems best at the moment and then solve the subproblems that arise later.
  • (^) The choice made by a greedy algorithm may depend on choices made so far but not on future choices or all the solutions to the subproblem.
  • (^) It iteratively makes one greedy choice after another, reducing each given problem into a smaller one.
  • (^) In other words, a greedy algorithm never reconsiders its choices. This is the main difference from dynamic programming, which is exhaustive and is guaranteed to find the solution.
  • (^) After every stage, dynamic programming makes decisions based on all the decisions made in the previous stage, and may reconsider the previous stage's algorithmic path to solution. 5

7

8

10

11