Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We want to paint our new fence, which is made up N boards. The lengths of the N boards are given in array L =
We want to paint our new fence, which is made up boards. The lengths of the boards are given in array We have hired painters, where each painter takes hour to paint unit of board. For example, if one of the painters paints boards and then
she completes at time Our goal is to assign each painter to some subset of boards, to minimize the time when the fence has been completely painted. Since the painters can work in parallel, this corresponds to minimizing max where is the time taken
by painter to complete her job. The painting task must be accomplished under the following constraints:
Each board must be completely painted by exactly one painter; ie no board can be painted partially by one painter and partially by another.
Each painter paints a contiguous collection of boards. For example, a configuration where painter paints boards and but not is not a valid solution.
You are given as input the following: the number of painters and an array with the board lengths. In the following problems, denote by the minimum time to paint the first i boards using painters. We will, successively in the following subtasks, come up with a procedure to
minimize the painting time.
a Write a recurrence for in terms of Do not forget base cases!
b Write an algorithm MinTime that computes the minimal completion time. To this end, complete the following skeleton. Make sure your algorithm uses only the minimal
amount of extra storage.
MinT ime
arr new array of length
for to do
for to do
for down to do
CALC
return
Next, write an algorithm CALC that calculates according to your recursive formula from part a Let denote the maximum time needed for CALC. You will obtain:
points for correctly completing the solution
points if your algorithm satisfies C On
an additional points if C ON
c When filling the table Tij in the previous part, does it matter wheterh the outer loop iterates over i and the inner of j or viceversa for correctness? What about the storage requirement? How much of the table do we need to keep stored in each order?
Step 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