Algorithm CS Problem T (20 points) How can we modify the CUT-ROD algorithm we st
ID: 3806810 • Letter: A
Question
Algorithm CS
Problem T (20 points) How can we modify the CUT-ROD algorithm we studied in class so that it imposes a fixed cost per cut when partitioning the rod into smaller pieces? Fill in each of the two boxes below with Java code that correctly completes the integer function bottom UpCutRodInclCutCost int [1 p, int n, int cost Percut which when passed (1) int array pCO nj (w here p [i] is the price for which an i-inch-long piece of rod can be sold); (2) int n (the total length in inches of a rod available for cutting: and (3) int cost Percut (a fixed cost incurred once for each cut made in the rod) returns the maximum net revenue (total sale price minus total cutting cost) that can be obtained by selling the rod after partitioning/cutting it into an optimally chosen set of smaller pieces (each of which has length equal to some positive integer number of inches). You should assume that pl01- 0 that p [i] 0 for all 0Explanation / Answer
The first blank should be filled with
pMinuscutcost[k]=p[I]-costPerCut;
Because it calculates the selling price of each piece minus the cut cost for each piece
Then the second blank should be filled with :
return q;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.