This preview shows page 1. Sign up to view the full content.
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 greedychoice property 1. Does making a greedy choice at any arbitrary point yield
an optimal solution? Consider an optimal solution to a subproblem Show that making the greedy choice will yield an optimal
solution to the overall problem Show that it has optimal substructure 2. 62 Show that a solution to a problem contains optimal
solutions to subproblems 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 maximumsize subset
of...
View Full
Document
 Spring '10
 HORTON
 Algorithms

Click to edit the document details