lecture16 - Lecture 16 Growth of functions Announcements Hw...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 16 Growth of functions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Announcements Hw due in one week (March 8) Quiz on 3/12
Background image of page 2
Algorithms recap An algorithm is a finite set of precise instructions for performing a computation that solves a problem Searching and sorting Worst case running time Optimization Knapsack, Change making Greedy Algorithms
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Greedy Climbing
Background image of page 4
Change Making Problem Input: n (cents), the amount of change Output: smallest amount of change: number of quarters, dimes, nickels and pennies E.g. 42 cents = 1 quarter, 1 dime, 1 nickel, 2 pennies
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The structure of change making Before solving any optimization problem, try to understand the structure of an optimal solution. Can you come up with properties of the optimal solution?
Background image of page 6
Properties of optimal change Lemma: If n is a positive integer, then n cents in change using quarters, dimes, nickels and pennies using the fewest number of coins has At most two dimes At most one nickel At most four pennies No two dimes and a nickel Total amount in dimes, nickels and pennies is at most 24 cents.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Greedy change making is optimal Proof by contradiction. Suppose there is an optimal algorithm OPT which produces less coins than greedy. Let’s compare each type of coin. The amount of quarters must be the same. Greedy produces the most possible amount of
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 29

lecture16 - Lecture 16 Growth of functions Announcements Hw...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online