02-greedy

14 5 3 8 6 5 7 7 5 9 8

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: als to schedule How long take? n = s.length A = {a1} k=1 for m = 2 to n if s[m] ≥ f[k] A = A U {am} k=m return A 61 does this Proving a greedy algorithm is correct Show that it fulfills the greedy-choice property 1. Does making a greedy choice at any arbitrary point yield an optimal solution? Consider an optimal solution to a sub-problem Show that making the greedy choice will yield an optimal solution to the overall problem Show that it has optimal sub-structure 2. 62 Show that a solution to a problem contains optimal solutions to sub-problems Warning! Proving that an algorithm makes a greedy choice at each stage is NOT the same as showing that the algorithm has the greedy choice property The first is a property of the algorithm designed The second shows that making the greedy choice will yield an optimal solution to the overall problem 63 The proof… The theorem we’ll prove (Cormen 16.1): Consider any nonempty subproblem Sk, and let am be an activity in Sk with the earliest finish time. Them am is included in some maximum-size subset of...
View Full Document

Ask a homework question - tutors are online