1 Greedy methods: Lecture 1 Jose Rolim University of Geneva.

Slides:



Advertisements
Similar presentations
Dynamic Programming 25-Mar-17.
Advertisements

1 Chapter 8 Approximation Algorithms (Part II). 2 Outline Scheduling Independent tasks Bin packing.
Algorithm Design Methods (I) Fall 2003 CSE, POSTECH.
Algorithm Design Methods Spring 2007 CSE, POSTECH.
Greedy Algorithms (Chap. 16)
Greedy Algorithms.
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.
1.1 Data Structure and Algorithm Lecture 6 Greedy Algorithm Topics Reference: Introduction to Algorithm by Cormen Chapter 17: Greedy Algorithm.
Chapter 5 Fundamental Algorithm Design Techniques.
Analysis of Algorithms
15-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 7: Greedy Algorithms
Greedy Algorithms. Announcements Exam #1 ◦ See me for 2 extra points if you got #2(a) wrong. Lab Attendance ◦ 12 Labs, so if anyone needs to miss a lab.
Merge Sort 4/15/2017 6:09 PM The Greedy Method The Greedy Method.
Lecture 3: Greedy Method Greedy Matching Coin Changing Minimum Spanning Tree Fractional Knapsack Dijkstra's Single-Source Shortest-Path.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2006 Lecture 2 Monday, 2/6/06 Design Patterns for Optimization.
Greedy Algorithms Reading Material: –Alsuwaiyel’s Book: Section 8.1 –CLR Book (2 nd Edition): Section 16.1.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 2 Monday, 9/13/06 Design Patterns for Optimization Problems.
CSE 780 Algorithms Advanced Algorithms Greedy algorithm Job-select problem Greedy vs DP.
Week 2: Greedy Algorithms
Fundamental Techniques
Lecture 7: Greedy Algorithms II
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.
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
Greedy Algorithms Fundamental Data Structures and Algorithms Peter Lee March 19, 2004.
Dynamic Programming. Algorithm Design Techniques We will cover in this class: ◦ Greedy Algorithms ◦ Divide and Conquer Algorithms ◦ Dynamic Programming.
Counting Coins. The Basics Quarter 25 cents Dime 10 cents.
For Wednesday No reading No homework There will be homework for Friday, as well the program being due – plan ahead.
The Greedy Method. The Greedy Method Technique The greedy method is a general algorithm design paradigm, built on the following elements: configurations:
CSC 201: Design and Analysis of Algorithms Greedy Algorithms.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
Greedy Algorithms BIL741: Advanced Analysis of Algorithms I (İleri Algoritma Çözümleme I)1.
Greedy Algorithms Interval Scheduling and Fractional Knapsack These slides are based on the Lecture Notes by David Mount for the course CMSC 451 at the.
Design and Analysis of Algorithms Introduction Instructors:1. B V Kiran Mayee, 2. A Madhavi
Algorithms Design and Analysis CS Course description / Algorithms Design and Analysis Course name and Number: Algorithms designs and analysis –
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.
Greedy Algorithms Lecture 10 Asst. Prof. Dr. İlker Kocabaş 1.
Greedy Algorithms Prof. Kharat P. V. Department of Information Technology.
Algorithm Design Methods
Merge Sort 7/29/ :21 PM The Greedy Method The Greedy Method.
The Greedy Method and Text Compression
Greedy Algorithm.
Greedy Algorithms.
Greedy Method     Greedy Matching     Coin Changing     Minimum Spanning Tree     Fractional Knapsack     Dijkstra's Single-Source Shortest-Path.
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 2:21 AM The Greedy Method The Greedy Method.
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
Exam 2 LZW not on syllabus. 73% / 75%.
Advanced Algorithms Analysis and Design
Greedy Algorithms.
Merge Sort 1/17/2019 3:11 AM The Greedy Method The Greedy Method.
Lecture 6 Topics Greedy Algorithm
Richard Anderson Lecture 6 Greedy Algorithms
Richard Anderson Autumn 2016 Lecture 7
Richard Anderson Lecture 7 Greedy Algorithms
Algorithm Design Methods
Lecture 6 Greedy Algorithms
Algorithm Design Methods
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.
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Asst. Prof. Dr. İlker Kocabaş
Advance Algorithm Dynamic Programming
Algorithm Design Methods
Richard Anderson Autumn 2019 Lecture 7
Presentation transcript:

1 Greedy methods: Lecture 1 Jose Rolim University of Geneva

2007 Algorithmique- Greedy 1 Jose Rolim2 Reference book  Book:

2007 Algorithmique- Greedy 1 Jose Rolim3 Also:  Brassard, Gilles et Bratley, Paul. Fundamentals of Algorithmics, Prentice- Hall. ISBN :  E. Horowitz, S. Sahni, and S. Rajasekaran. Computer Algorithms. W. H. Freeman Press, 1997.

2007 Algorithmique- Greedy 1 Jose Rolim4 Evaluation  Written Exam  No C.C  Program Challenge

2007 Algorithmique- Greedy 1 Jose Rolim5 Program  Greedy – JR (2 weeks)  Divide and Conquer – BC (2 weeks)  Dynamic Programming – JR (2 weeks)  Backtracking – BC (2 weeks)  Advanced Graph Algorithms – JR (2 weeks)  Branch and Bound – BC (2 weeks)

2007 Algorithmique- Greedy 1 Jose Rolim6 Courses  Monday at Uni-Dufour  Wednesday at Battelle

2007 Algorithmique- Greedy 1 Jose Rolim7 Greedy - Principles  Optimization problem  Best choice at any moment  Basic steps:  Define the problem and corresponding greedy strategy  Show that greedy approach leads to optimal solution

2007 Algorithmique- Greedy 1 Jose Rolim8 Previous examples  BSF  DSF  ????

2007 Algorithmique- Greedy 1 Jose Rolim9 Ex: Making changes  A dollar amount to reach and a collection of coins amount to get there  PROBLEM:  Minimize the number of coins returned

2007 Algorithmique- Greedy 1 Jose Rolim10 Example 1:  Amount to be returned: 2.89  Coins available:  100 cents  25 cents  10 cents  5 cents  1 cent

2007 Algorithmique- Greedy 1 Jose Rolim11 Solution  10 coins:  2 dollars  3 quarters  1 dime  4 pennies

2007 Algorithmique- Greedy 1 Jose Rolim12 Greedy strategy  At every stage add a coin of the largest possible value that does not pass the amount to be paid  Does the greed strategy always work????  YES. For this set of coins  NOT NECESSARLY for another set (EX???)

2007 Algorithmique- Greedy 1 Jose Rolim13 Knapsack

2007 Algorithmique- Greedy 1 Jose Rolim14 Knapsack  0-1 knapsack problem:  How to fill the knapsack with best total value w/o breaking each item  Fractional knapsack problem:  How to fill the knapsack with best total value

2007 Algorithmique- Greedy 1 Jose Rolim15 Solutions ????  NP- hard for 0-1 knapsack  Greedy for fractional knapsack  Compute value per pound (VPP) for each item  Take as much as possible of the item with largest VPP  Continue till reach weight limit

2007 Algorithmique- Greedy 1 Jose Rolim16 Example $60$100$120 VPP:654 Knapsack: hole weight

2007 Algorithmique- Greedy 1 Jose Rolim17 Greedy Fails for 0-1 Knapsack $60$100$120 VPP: $ $ $220

2007 Algorithmique- Greedy 1 Jose Rolim18 Task scheduling problem  We have a set T of N tasks, each with a start time si and a finishing time fi (si<fi).  Each task must start at time si and will finish at time fi.  Each task is executed on a machine Mj.  A machine can execute only one task at a time, but can start a task at the same time as the current task ends (red lines on the figure to the right).  Tasks are non-conflicting if they do not conflict, i.e., if fi≤sj or fj≤si. For example, think of tasks as classes.  The problem is to schedule all the tasks in T using the minimal number of machines.

2007 Algorithmique- Greedy 1 Jose Rolim19 Example  There are 6 tasks, with start times and finishing times (1,3), (2,5), (2,6), (4,5), (5,8), (5,7).

2007 Algorithmique- Greedy 1 Jose Rolim20 Greedy strategy  In our greedy strategy we only go to a new machine when we find a task that cannot be scheduled on the current machines

2007 Algorithmique- Greedy 1 Jose Rolim21 In the example  They are scheduled on three machines M1, M2, M3.  Clearly 3 machines are needed as can be seen by looking at time 4.