Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone help me to solve it, please? The second picture is the continuation of the first question. P.1 (20 pts) In the weighted interval
Can someone help me to solve it, please? The second picture is the continuation of the first question.
P.1 (20 pts) In the weighted interval scheduling problem, we are given njobs, each of which has a start time, finish time, and weight. We say that two jobs are compatible if they do not overlap in time. We want to find the subset of compatible jobs with the maximum weight. In the figure below, the numbers in the rectangles represent the job weight. Jobs 1 W-3 W-2 2 3 W-4 4 W1 5 W-3 6 W-4 7 W=3 8 W-1 10 0 1 2 3 4 5 7 8 9 11 12 6 Time Figure 1 Weighted Intervals Scheduling: Jobs intervals and weights a. (15 pts.) Fill in the table below and calculate p) and M[] columns, using the iterative algorithm we discussed in the class, memoizing the result in the M[] array. Compute P(1), P(2), - P(n) Iterative-Compute-Opt { M[O] -0 for j - 1 ton MD) - max (wj + MPG)], M-1]) } Start Finish Weight PC) MO Solution Job 1 2 3 4 5 6 7 8 b. (5 pts.) Once we are done executing the algorithm in (a), we have computed the total weight of the optimal schedule. However, we don't actually know which jobs to include. To extract that information, we will use a recursive a. (15 pts.) Fill in the table below and calculate p() and M[] columns, using the iterative algorithm we discussed in the class, memoizing the result in the M[] array. Compute P(1), P(2) - P(n) Iterative-Compute-Opt { M[0] =0 for j = 1 ton M[j] = max(wj + M[P(j)), M[j-1]) } Start Finish Weight PO) M[] Solution Job 1 2 3 4 5 6 7 8 b. (5 pts.) Once we are done executing the algorithm in (a), we have computed the total weight of the optimal schedule. However, we don't actually know which jobs to include. To extract that information, we will use a recursive return algorithm Find-Solution, calling Find-Solution (n). Use this to fill in the last column of your table. Then list the jobs that provide maximum weight. Find-Solution(j) { if (j = 0) else if (Wj + M[P()] > M[j-1]) Find-Solution (P(j)) j is in the solution Find-Solution (j-1) } elseStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started