Week 5 Objectives. Subproblem structure Greedy algorithm Mathematical induction application Greedy correctness

Similar documents
-- Final exam logistics -- Please fill out course evaluation forms (THANKS!!!)

How Many of Each Kind?

-- CS341 info session is on Thu 3/18 7pm in Gates Final exam logistics

Lecture 9: Tuesday, February 10, 2015

Incremental Record Linkage. Anja Gruenheid!! Xin Luna Dong!!! Divesh Srivastava

Introduction to Management Science Midterm Exam October 29, 2002

Concepts/Skills. Materials

RISK ASSESSMENT DEPT. OF AGROINDUSTRIAL TECHNOLOGY FACULTY OF AGRICULTURAL TECHNOLOGY UNIVERSITAS BRAWIJAYA

John Perry. Fall 2009

Economics Homework 4 Fall 2006

DEVELOPING PROBLEM-SOLVING ABILITIES FOR MIDDLE SCHOOL STUDENTS

A Note on H-Cordial Graphs

What Is This Module About?

Decision making with incomplete information Some new developments. Rudolf Vetschera University of Vienna. Tamkang University May 15, 2017

Unit 2, Lesson 15: Part-Part-Whole Ratios

MAMA SID'S PIZZA by Faith Goddard-Allen

Archdiocese of New York Practice Items

International Collegiate Programming Contest South German Winter Contest. January 31, 2009

Unit 2, Lesson 15: Part-Part-Whole Ratios

Recursion. John Perry. Spring 2016

Alisa had a liter of juice in a bottle. She drank of the juice that was in the bottle.

7.RP Cooking with the Whole Cup

Mix it Up: Combining Liquids of Different Temperature

Grade 5 / Scored Student Samples ITEM #5 SMARTER BALANCED PERFORMANCE TASK

Missing value imputation in SAS: an intro to Proc MI and MIANALYZE

CMC DUO. Standard version. Table of contens

Performance Task: FRACTIONS! Names: Date: Hour:

This problem was created by students at Western Oregon University in the spring of 2002

longer any restriction order batching. All orders can be created in a single batch which means less work for the wine club manager.

SYSTEMS OF LINEAR INEQUALITIES

Lesson 9: Tables of Equivalent Ratios

Caffeine And Reaction Rates

STACKING CUPS STEM CATEGORY TOPIC OVERVIEW STEM LESSON FOCUS OBJECTIVES MATERIALS. Math. Linear Equations

Quotient Cordial Labeling of Graphs

CS 322: (Social and Information) Network Analysis Jure Leskovec Stanford University

MULTICRITERIA DECISION AIDING

0648 FOOD AND NUTRITION

Feeling Hungry. How many cookies were on the plate before anyone started feeling hungry? Feeling Hungry. 1 of 10

2016 China Dry Bean Historical production And Estimated planting intentions Analysis

0648 FOOD AND NUTRITION

From Waste Stream To Protein! Closed Loop Mushroom Production on 100% Waste Stream Substrate

Making Cookies: Problem Solving

0648 FOOD AND NUTRITION

Economics 101 Spring 2016 Answers to Homework #1 Due Tuesday, February 9, 2016

Chapter 1: The Ricardo Model

Chapter 3 Labor Productivity and Comparative Advantage: The Ricardian Model

Joy the Baker Rationalizing in Baking

Master planning in semiconductor manufacturing exercise

!!!! !!! !!! !!!! !!! Review Fractions Solve 5 problems every day. An expression is shown.

The aim of the thesis is to determine the economic efficiency of production factors utilization in S.C. AGROINDUSTRIALA BUCIUM S.A.

MARK SCHEME for the May/June 2006 question paper 0648 FOOD AND NUTRITION

Lesson 41: Designing a very wide-angle lens

Investigation 1: Ratios and Proportions and Investigation 2: Comparing and Scaling Rates

Objective: Decompose a liter to reason about the size of 1 liter, 100 milliliters, 10 milliliters, and 1 milliliter.

Going Strong. Comparing Ratios. to Solve Problems

Investigation 1: Ratios and Proportions and Investigation 2: Comparing and Scaling Rates

MEGA TRIEUR. Seed Conditioning & Processing Global Solution Partner. Maximum-precision sorting. Application/characteristics.

Lesson 41: Designing a very wide-angle lens

Pg. 2-3 CS 1.2: Comparing Ratios. Pg CS 1.4: Scaling to Solve Proportions Exit Ticket #1 Pg Inv. 1. Additional Practice.

Fraction Word Problems: Do I Multiply or Divide?

Thought: The Great Coffee Experiment

Chapter 3. Labor Productivity and Comparative Advantage: The Ricardian Model. Pearson Education Limited All rights reserved.

Alcoholic Fermentation in Yeast A Bioengineering Design Challenge 1

Student Booklet 1. Mathematics Examination Secondary Cycle One Year One June Competency 2 Situations No calculator allowed

Math Fundamentals PoW Packet Cupcakes, Cupcakes! Problem

Lesson 11: Comparing Ratios Using Ratio Tables

Chapter 3. Labor Productivity and Comparative Advantage: The Ricardian Model

Preview. Chapter 3. Labor Productivity and Comparative Advantage: The Ricardian Model

Thermal Hydraulic Analysis of 49-2 Swimming Pool Reactor with a. Passive Siphon Breaker

Your Professional Partner in Instant Coffee. A Company of Neumann Kaffee Gruppe

FIRST MIDTERM EXAM. Economics 452 International Trade Theory and Policy Fall 2010

Math Released Item Grade 5. Bean Soup M01289

Cinnamon Raisin Bread. 4 2/3 cups cup 1 cup 2 TBSP. 1 1/4 tsp. 1 cups. Strawberry Cake. 2 3/4 cup and 2 TBSP. 2 cups tsp.

CERT Exceptions ED 19 en. Exceptions. Explanatory Document. Valid from: 26/09/2018 Distribution: Public

Preview. Introduction. Chapter 3. Labor Productivity and Comparative Advantage: The Ricardian Model

FIRST MIDTERM EXAM. Economics 452 International Trade Theory and Policy Spring 2010

2008 Excellence in Mathematics Contest Team Project Level I (Precalculus and above) School Name: Group Members:

Amazing Antioxidants. Investigating Your Health: Name:

Herbacel - AQ Plus Citrus. for optimising the quality, calorie content and cost of burger patties

Coffee (lb/day) PPC 1 PPC 2. Nuts (lb/day) COMPARATIVE ADVANTAGE. Answers to Review Questions

Grocery List (Step 2)

Divide by 2-Digit Divisors. How can you divide by 2-digit divisors?

STA Module 6 The Normal Distribution

STA Module 6 The Normal Distribution. Learning Objectives. Examples of Normal Curves

Mini Project 3: Fermentation, Due Monday, October 29. For this Mini Project, please make sure you hand in the following, and only the following:

NomaSense PolyScan. Analysisof oxidizable compounds in grapes and wines

QUALITY DESCRIPTOR / REPRESENTATIONS GUIDELINES FOR THE

Fractions with Frosting

Preview. Introduction. Chapter 3. Labor Productivity and Comparative Advantage: The Ricardian Model

I know what capacity is and can estimate the capacity of items using known items as a personal reference.

The Bottled Water Scam

Innovations for a better world. Ingredient Handling For bakeries and other food processing facilities

Metric Units for Liquid Volume. How can you measure liquid volume in metric units?

Instruction (Manual) Document

WineScan All-in-one wine analysis including free and total SO2. Dedicated Analytical Solutions

Fraction Conundrums. Warm Up Questions. Create Your Own Scenario

THE 900 DAYS - THE SIEGE OF LENINGRAD "SALISBURY BY HARRISON E." 14.8

Amazing Antioxidants. Investigating Your Health: Name:

Feb 5, 2019 Senate Committee on Business and General Government RE: SB390 - Relating to the sale of olive oil

Transcription:

Greedy Algorithms

Week 5 Objectives Subproblem structure Greedy algorithm Mathematical induction application Greedy correctness

Subproblem Optimal Structure Divide and conquer - optimal subproblems divide PROBLEM into SUBPROBLEMS, solve SUBPROBLEMS combine results (conquer) critical/optimal structure: solution to the PROBLEM must include solutions to subproblems (or subproblem solutions must be combinable into the overall solution) PROBLEM = {DECISION/MERGING + SUBPROBLEMS}

Optimal Structure - GREEDY PROBLEM = {DECISION/MERGING + SUBPROBLEMS} GREEDY CHOICE: can make the DECISION without solving the SUBPROBLEMS - the GREEDY CHOICE looks good at the moment, and it is globally correct - example : pick the smallest value - solve SUBPROBLEMS after decision is made GREEDY CHOICE: after making the DECISION, very few SUBPROBLEMS to solve (typically one)

Optimal Structure - NON GREEDY Cannot make a choice decision/choice without solving subproblems first Might have to solve many subproblems before deciding which results to merge.

Ex: Fractional Knapsack fractional goods (coffee, tea, flour, maize...) sold by weight supply (weights/quantities available) w1,w2,w3,w4... values (totals) v1,v2,v3,v4... - ex: coffee w1=10pounds; coffee overall value v1=$40 knapsack capacity (weight) = W task : fill the knapsack to maximize value

Ex: Fractional Knapsack 70 weight=70 Weight available 52.5 35 17.5 weight=25 weight=50 weight=20 0 coffee val=30 tea val=40 flour val=15 maize val=10 naive approaches may lead to a bad solution - choose by biggest value - tea first - choose by smallest quantity - flour first choose by quality is correct- coffee first - q coffee =30/25; q tea =40/50; q flour =15/20; q maize =10/70

Ex: Fractional Knapsack solution: compute item quality (value/weight) q i =v i /w i sort items by quality q1>q2>q3>... LOOP - take as much as possible of the best quality - if knapsack full, STOP - if stock depletes (knapsack not full), move on to the next quality item, repeat - END LOOP

Fractional Knapsack - greedy proof proving now that the greedy choice is optimal - meaning that the solution includes the greedy choice. greedy choice: take as much as possible form best quality (below item with quality q1) - items available sorted by quality: q1>q2>q3>..., greedy choice is to take as much as possible of item 1, that is quantity w1 contradiction/exchange argument - suppose that best solution doesnt include the greedy choice: SOL=(r1,r2,r3,...) quantities chosen of these items, and that r1 is not the max quantity available (of max quality item), r1<w1 - create a new solution SOL from SOL by taking more of item 1 and less of the others - e=min(r2,w1-r1); SOL =(r1+e,r2-e,r3,r4...) - value(sol ) - value(sol) = e(q1-q2)>0 which means SOL is better than SOL: CONTRADICTING that SOL is best solution

Fractional Knapsack - greedy proof english explanation: - say coffee is the highest quality, - the greedy choice is to take max possible of coffee which is w1=10pounds contradiction/exchange argument - suppose that best solution doesnt include the greedy choice: SOL=(8pounds coffee, r2 of tea, r3 flours,...) r1=8pounds<w1=10pounds - create a new solution SOL from SOL by taking out 2pounds of tea and adding 2 pounds of coffee; e=2pounds - e=min(r2,w1-r1); SOL =(r1+e,r2-e,r3,r4...) - value(sol ) - value(sol) = e(q1-q2)>0 which means SOL is better than SOL: CONTRADICTING that SOL is best solution

Activity Selection Problem S=set of n activities given by start and finish time a i = (s i,f i ) i=1:n, f i >s i Determine a selection that gives a maximal set - select maximum number of activities - no overlapping activities can be selected

Activity Selection Problem Greedy solution: sort activities by their finishing time - f1<f2<f3... - select the activity that finishes first a = (s 1,f 1 ) - discard all overlapping activities with selected one : discard all activities with starting time s i <f 1 - repeat intuition: activity that finishes first is the one that leaves as much time as possible for other activities

Activity Selection Problem Proof of greedy choice optimality - activities sorted by finishing time f1<f2<f3... - greedy choice pick the activity a with earliest finishing time f1 - want to show that activity a is included in one of the best solutions (could be more than one optimal selection of activities) Exchange argument - SOL a best solution. - if SOL includes a, done. - suppose the best solution does not select a, SOL= (b,c,d,...) sorted by finishing time f b <f c <f d. Then create a new solution that replaces b with a SOL =(a, c, d,...). - This solution SOL is valid, a and c dont overlap: s c >f b >f a - SOL is as good as SOL (same number of activities) and includes a

Mathematical Induction property P(n) = {TRUE, FALSE} for n=integer - want to prove P(n)=TRUE for all n Base cases: P(n)=TRUE for any n n 0 Induction Step: prove P(n+1) for next value n+1 - if P(t)=TRUE for certain values of t<n+1 then prove by mathematical derivation/arguments than P(n+1)=TRUE Then P(n) = TRUE for all n

Mathematical Induction- Example P(n): 1+2+3+...+n = n(n+1)/2 base case n=1 : 1=1*2/2 - correct induction step : lets prove P(n+1) assuming P(n) - P(n+1) : 1+2+3+...+n + (n+1) = (n+1)(n+2)/2. - assuming P(n) TRUE : 1+2+3...+(n+1) = [1+2+3+...+n] + (n+1) = n(n+1)/2 + (n+1) = (n+1)(n+2)/2; so P(n+1) TRUE thus P(n) TRUE for all n>0

Activity Selection - Induction Argument s(a)= start time; f(a)=finish time SOL={a 1,a 2,...,a k } greedy solution - chosen by earliest finishing time OPT = {b 1,b 2,...,b m } optimal solution, sorted by finishing time; optimal means m max possible prove by induction that f(a i ) f(b i ) for all i=1:k - base case f(a 1 ) f(b 1 ) because f(a 1 ) smallest in the whole set - inductive step: assume f(a n-1 ) f(b n-1 ). Then b n is a valid choice for greedy at step n because f(a n-1 ) f(b n-1 ) s(b n ). Since greedy picked a n over b n, it must be because an fits the greedy criteria f(a n ) f(b n ) so f(a k ) f(b k ). If m>k then any b k+1 item would also fit into greedy solution (CONTRADICTION) thus m=k