3 3 votes You are given a rod of length $n$ and an array prices where prices[i] is the selling price of a piece of length i . A fixed cost c is incurred for every cut made. Let $P[i]$ be the maximum profit from a rod of length $i$. Which of the following descriptions accurately represents the calculation for $P[i]$ ? (Assume $P[0]=0$ ).$P[i]=\max _{1 \leq j \leq i}(\operatorname{prices}[j]+P[i-j]-c)$ $P[i]=\max \left(\operatorname{prices}[i], \max _{1 \leq j<i}(P[j]+P[i-j]-c)\right)$ $P[i]=\max \left(\operatorname{prices}[i]-c, \max _{1 \leq j<i}(P[j]+P[i-j])\right)$ $P[i]=\left(\max _{1 \leq j \leq i}(\operatorname{prices}[j]+P[i-j])\right)-c$ Algorithms goclasses algorithms goclasses-cs-dpp goclasses-cs-dpp-day-89 goclasses-algorithms-practice-questions + – GO Classes 323 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote The problem is rod-cutting with a cut cost of c.Key points:If we cut a rod of length $i$ into two pieces of lengths $j$ and $i-j$,we earn prices[j] + P[i-j]but we pay c once for that cut.We also have the option of not cutting at all, selling the rod whole for prices[i], which incurs no cost.The correct recurrence must therefore take the maximum of:selling whole: prices[i]best first-cut: prices[j] + P[i-j] - c for some $1 \leq j<i$.Among the choices:(B)$$P[i]=\max \left(\operatorname{prices}[i], \max _{1 \leq j<i}\{P[j]+P[i-j]-c\}\right)$$This exactly matches the reasoning above. GO Classes answered Sep 20, 2025 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.