Module4_08 - Greedy Algorithms TOPICS Greedy Strategy...

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

View Full Document Right Arrow Icon
9/21/2008 CSE 5311 Fall 2008 M Kumar 1 Greedy Algorithms TOPICS Greedy Strategy Activity Selection Minimum Spanning Tree Shortest Paths Huffman Codes Fractional Knapsack Chapter 5 Algorithm Design Kleinberg and Tardos
Background image of page 1

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

View Full DocumentRight Arrow Icon
9/21/2008 CSE 5311 Fall 2008 M Kumar 2 The Greedy Principle The problem: We are required to find a feasible solution that either maximizes or minimizes a given objective solution . It is easy to determine a feasible solution but not necessarily an optimal solution. The greedy method solves this problem in stages, at each stage, a decision is made considering inputs in an order determined by the selection procedure which may be based on an optimization measure. The greedy algorithm always makes the choice that looks best at the moment. For each decision point in the greedy algorithm, the choice that seems best at the moment is chosen It makes a local optimal choice that may lead to a global optimal choice.
Background image of page 2
9/21/2008 CSE 5311 Fall 2008 M Kumar 3 Activity Selection Problem Scheduling a resource among several competing activities. S = {1,2, 3, …, n } is the set of n proposed activities The activities share a resource, which can be used by only one activity at a time -a Tennis Court, a Lecture Hall etc., Each activity i has a start time, s i and a finish time f i , where s i f i . When selected, the activity takes place during time ( s i , f i ) Activities i and j are compatible if s i f j or s j f i The activity-selection problem selects the maximum-size set of mutually compatible activities The input activities are in order by increasing finishing times. f 1 f 2 f 3 f n ; Can be sorted in O ( n log n ) time
Background image of page 3

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

View Full DocumentRight Arrow Icon
9/21/2008 CSE 5311 Fall 2008 M Kumar 4 Procedure for activity selection (from CLRS) Procedure GREEDY_ACTIVITY_SELECTOR( s, f ) n length [ S ]; in order of increasing finishing times; A {1}; first job to finish j 1; for i 2 to n do if s i f j then A A { i }; j i ;
Background image of page 4
9/21/2008 CSE 5311 Fall 2008 M Kumar 5 is i f i 11 4 23 5 30 6 45 7 53 8 65 9 76 1 0 88 1 1 98 1 2 10 2 13 11 12 14 Initially we choose activity 1 as it has the least finish time.
Background image of page 5

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

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

This document was uploaded on 11/18/2009.

Page1 / 20

Module4_08 - Greedy Algorithms TOPICS Greedy Strategy...

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

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