greedy - Greedy Methods Greedy Methods Problems whose...

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

View Full Document Right Arrow Icon
reedy Methods Greedy Methods
Background image of page 1

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

View Full DocumentRight Arrow Icon
roblems whose solutions can be “ranked” Problems whose solutions can be ranked Travel Investment Course lection selection Feasible solutions stay on highway, finish in x days don’t spend more than one has finish in 4 years Optimal solutions shortest distance, minimum time maximum returns, minimum best combination risk so f depth and breadth ecisions hich highways vest or not in a ke a course Decisions which highways to take invest or not in a portfolio take a course or not Data Structures and Algorithms II
Background image of page 2
ecisions can be made Decisions can be made one at a time, without backtracking Greedy method Which decisions to make next ? How to guarantee optimality? Try many (all) possible combinations and yy ( ) p choose one which is the best ynamic programming Dynamic programming How to test multiple solutions efficiently? Data Structures and Algorithms II
Background image of page 3

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

View Full DocumentRight Arrow Icon
he Greedy Method The Greedy Method Input n elements stored in an array A ( 1:n ) Procedure Greedy Solution = NULL for i=1 to n do x = SELECT( A ) if FEASIBLE(Solution, x) then Solution = UNION(Solution, x) endif enddo Data Structures and Algorithms II return (Solution)
Background image of page 4
A sequence of n decisions w.r.t n inputs q p SELECT: select one of the remaining ecisions to make according to some decisions to make according to some optimization measure nce a decision is made it will ot ecome once a decision is made, it will not become invalid at a later time ptimization ould be based on the partial optimization should be based on the partial solutions built so far EASIBLE: hether the partial solution FEASIBLE: whether the partial solution satisfies some preset constraints Data Structures and Algorithms II
Background image of page 5

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

View Full DocumentRight Arrow Icon
trategy construct feasible solutions one Strategy : construct feasible solutions one step at a time which optimize (minimize or maximize) a certain objective function Make the obvious decisions first ! Then try to show it is indeed optimal! Data Structures and Algorithms II
Background image of page 6
napsack problem Knapsack problem Input: a set of n objects a knapsack of capacity M (, ) , . . . , PW i n ii 1 Output: fill the knapsack to maximize the total profit earned p Feasibility constraint: WX M i n 1 Objective function: max PX X i n i  1 01 Data Structures and Algorithms II
Background image of page 7

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

View Full DocumentRight Arrow Icon
Example p n M  32 0 , PPP WWW 25 2415 181510 123 (, , ) ( , , ) , )(, ,) XX X W X P X ii i n i n 2 11 , ) t i if i t 1 15 0 20 28 2 0 2 12 0 3 1 ( ,, ) . (, ,) largest increase in profit smallest increase in weight 3 01 1 2 315 (,, ) . largest increase in profit to weight ratio Data Structures and Algorithms II ( . , . , . P W P W P W 1 1 2 2 3 3 1391615)
Background image of page 8
For all three algorithms decisions are made one object at a time the ordering is determined by some ti i ti optimization measure Largest increase in profit clude the remaining object of the largest profit Include the remaining object of the largest profit Smallest increase in weight
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/19/2012 for the course ENGR 361 taught by Professor Drexel during the Spring '12 term at Bloomsburg.

Page1 / 79

greedy - Greedy Methods Greedy Methods Problems whose...

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

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