Question: Give a dynamic-programming algorithm for the activity-selection problem, based on recurrence (16.2). Have your algorithm compute the sizes c[I, j] as defined above and also

Give a dynamic-programming algorithm for the activity-selection problem, based on recurrence (16.2). Have your algorithm compute the sizes c[I, j] as defined above and also produce the maximum-size subset of mutually compatible activities. Assume that the inputs have been sorted as in equation (16.1). Compare the running time of your solution to the running time of GREEDY-ACTIVITY-SELECTOR.

(16.2)

if Sij = Ø , max {c[i,k]+ c[k, j]+ 1} _if Sij + Ø . c[i, j]= ak ES¡J

(16.1)

ш ши a1 RECURSIVE-ACTIVITY-SELECTOR(S, f, 0, 11) Ш ш 2 3 5 RECURSIVE-ACTIVvrTY-SELECTOR(S, f, 1, 11) a1 3 0 6 a1 a4

if Sij = , max {c[i,k]+ c[k, j]+ 1} _if Sij + . c[i, j]= ak ESJ a1 RECURSIVE-ACTIVITY-SELECTOR(S, f, 0, 11) 2 3 5 RECURSIVE-ACTIVvrTY-SELECTOR(S, f, 1, 11) a1 3 0 6 a1 a4 4 5 7 m = 4 RECURSIVE-ACTIVITY-SELECTOR(s,f, 4, 11) as 5 a6 6 5 9 7 6 10 a4 ag 8 8 11 a1 nn a4 RECURSIVE-ACTIVITY-SELECTOR(s, f, 8, 11) 12 ag 10 2 14 ug 11 12 16 m = 11: umnum a1 a4 ag RECURSIVE-ACTIVITY-SELECTOR(Ss, f, 11, 11) ag a11 time 3 4 6. 10 11 12 13 14 15 16 9. 3.

Step by Step Solution

3.37 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The tricky part is determining which activities are in the set S ij If activitykis inS ij then we mu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction to Algorithms Questions!