Greedy Algorithms Kevin Kauffman CS 309s.

Slides:



Advertisements
Similar presentations
Algorithm Design Methods (I) Fall 2003 CSE, POSTECH.
Advertisements

Algorithm Design Methods Spring 2007 CSE, POSTECH.
Greedy Algorithms (Chap. 16)
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
The Greedy Method1. 2 Outline and Reading The Greedy Method Technique (§5.1) Fractional Knapsack Problem (§5.1.1) Task Scheduling (§5.1.2) Minimum Spanning.
Chapter 5 Fundamental Algorithm Design Techniques.
Analysis of Algorithms
Greedy Algorithms Spanning Trees Chapter 16, 23. What makes a greedy algorithm? Feasible –Has to satisfy the problem’s constraints Locally Optimal –The.
Greedy Algorithms Be greedy! always make the choice that looks best at the moment. Local optimization. Not always yielding a globally optimal solution.
Greedy Algorithms Basic idea Connection to dynamic programming
Greedy Algorithms Basic idea Connection to dynamic programming Proof Techniques.
Cs333/cutler Greedy1 Introduction to Greedy Algorithms The greedy technique Problems explored –The coin changing problem –Activity selection.
CSE 421 Algorithms Richard Anderson Lecture 6 Greedy Algorithms.
Week 2: Greedy Algorithms
1 The Greedy Method CSC401 – Analysis of Algorithms Lecture Notes 10 The Greedy Method Objectives Introduce the Greedy Method Use the greedy method to.
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
Introduction to Computer Science. A Quick Puzzle Well-Formed Formula  any formula that is structurally correct  may be meaningless Axiom  A statement.
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
Called as the Interval Scheduling Problem. A simpler version of a class of scheduling problems. – Can add weights. – Can add multiple resources – Can ask.
Bold Stroke January 13, 2003 Advanced Algorithms CS 539/441 OR In Search Of Efficient General Solutions Joe Hoffert
9/8/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 6 Greedy Algorithms.
Image segmentation Prof. Noah Snavely CS1114
Algorithmics - Lecture 101 LECTURE 10: Greedy technique.
Greedy Algorithms. Surprisingly, many important and practical computational problems can be solved this way. Every two year old knows the greedy algorithm.
Lectures on Greedy Algorithms and Dynamic Programming
Greedy Algorithms. An Ambitious Plan Introduction Commando War Bridge Minimal Coverage All in all Ferry Loading II Making Change Introspective Caching.
Chapter 9 Finding the Optimum 9.1 Finding the Best Tree.
1 Chapter 5-1 Greedy Algorithms Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Algorithm Design Methods 황승원 Fall 2011 CSE, POSTECH.
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
HKOI 2004 Team Training Greedy Algorithms (Intermediate Level)
Spring 2008The Greedy Method1. Spring 2008The Greedy Method2 Outline and Reading The Greedy Method Technique (§5.1) Fractional Knapsack Problem (§5.1.1)
CS 361 – Chapter 10 “Greedy algorithms” It’s a strategy of solving some problems –Need to make a series of choices –Each choice is made to maximize current.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
CSE 421 Algorithms Richard Anderson Lecture 8 Greedy Algorithms: Homework Scheduling and Optimal Caching.
CSCI 58000, Algorithm Design, Analysis & Implementation Lecture 12 Greedy Algorithms (Chapter 16)
CSC317 Greedy algorithms; Two main properties:
Greedy Technique.
We consider the problem of optimally arranging files on a tape
Algorithm Design Methods
Greedy Algorithms Basic idea Connection to dynamic programming
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Presented by Po-Chuan & Chen-Chen 2016/03/08
Greedy Algorithms.
Richard Anderson Autumn 2015 Lecture 8 – Greedy Algorithms II
Merge Sort 11/28/2018 2:18 AM The Greedy Method The Greedy Method.
The Greedy Method Spring 2007 The Greedy Method Merge Sort
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
CS4335 Design and Analysis of Algorithms/WANG Lusheng
Greedy Algorithms.
Greedy Algorithms: Homework Scheduling and Optimal Caching
Merge Sort 1/17/2019 3:11 AM The Greedy Method The Greedy Method.
Richard Anderson Lecture 6 Greedy Algorithms
Richard Anderson Autumn 2016 Lecture 7
Richard Anderson Lecture 7 Greedy Algorithms
Richard Anderson Winter 2019 Lecture 8 – Greedy Algorithms II
Algorithm Design Methods
Algorithm Design Methods
Richard Anderson Autumn 2016 Lecture 8 – Greedy Algorithms II
The results for Challenging Problem 1.
Richard Anderson Winter 2019 Lecture 7
Merge Sort 5/2/2019 7:53 PM The Greedy Method The Greedy Method.
Week 2: Greedy Algorithms
Richard Anderson Autumn 2015 Lecture 7
CS 6310 Advanced Design and Analysis of Algorithms Rajani Pingili
More NP-Complete Problems
Algorithm Design Methods
Richard Anderson Autumn 2019 Lecture 7
Richard Anderson Autumn 2019 Lecture 8 – Greedy Algorithms II
Presentation transcript:

Greedy Algorithms Kevin Kauffman CS 309s

No decision we make now can come back to hurt us later! What is Greedy? For each decision you make, the locally optimal choice will lead to the globally optimal solution There is some hard and fast rule that you can apply every time No decision we make now can come back to hurt us later!

Making Change If I ask you to make 47¢ in change, how do you go about doing it? Is there a rule we can apply for making change for arbitrary amounts of money? Does this rule still apply if we change the values and coins available (say, removing the nickel and asking for 30¢)?

Proving that Greedy is Correct Greedy proofs are often tricky Often must rely on intuition during contests Think: is there any non-greedy selection that I could make that would yield a more optimal solution? Can I show that any non-greedy selection must necessarily lead to a equally or less optimal solution?

Task Completion What method do you use? Suppose we have a set of tasks (perhaps class projects), and each task must be completed by a fixed time. Determine whether you can complete all tasks on time What method do you use?

Task Completion Rule: solve the outstanding task with the earliest deadline first How do we know this is correct?

Proof Say d(A) and d(B) are the first two deadlines If we solve them in the order of the deadlines, A < d(A) and A+B < d(B) Suppose we flip the problems Now A+B < d(A) and d(A) < d(B), so A+B < d(B) The constraints on d(A) are now tighter, while the constraint on d(B) remained the same!

Proof The best ordering of any pair is to complete the one with the earliest deadline first The only ordering which satisfies this for all consecutive pairs of tasks is completing the tasks in deadline order Didn’t NEED to prove this (proof is trivial), but its important to understand the method, since sometimes you need to see intuitively how any non greedy selection can’t make the solution worse

Problem Walkthrough Dennis Matveyev Programming Contest 2010: Coins (Problem A)