Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1 (15 points) How can we modify the CUT-ROD algorithm that we studied in

ID: 3734945 • Letter: P

Question

Problem 1 (15 points) How can we modify the CUT-ROD algorithm that 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 three boxes below with Java code that correctly completes the integer function bottomUpCutRodInclcutCost ( int[P, int n, int costPercut ) which when passed: (1) int array p[0..n) (where 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 costPercut (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 p[0]=0; that p[i]>0 for all 0

Explanation / Answer

The following are the fragment that needs to be filled in the above code.

1. pMinusCutCost[k] = p[k] - costPerCut;
2. q = max(q, p[i] + r[j-i-1]);
3. return r[n];

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote