plz explain the b-p solution how to drive the relation…
Bottom up approach not clear
@dakshi hey ,please refer to this video ,you will get it and if you still have any doubt then please ask:
Sir, not clear
table mein columns denote 0-length
rows…
dp[i][j] what it means? how to calculate it interms of lower boundary;
@dakshi hey here is much simpler code with 1d dp:
int
cutRod(
int
price[],
int
n)
{
int
val[n+1];
val[0] = 0;
int
i, j;
// Build the table val[] in bottom up manner and return the last entry
// from the table
for
(i = 1; i<=n; i++)
{
int
max_val = INT_MIN;
for
(j = 0; j < i; j++)
max_val = max(max_val, price[j] + val[i-j-1]);
val[i] = max_val;
}
return
val[n];
}
here i represents the value jha cut lga rge hai and val(i) reprrsents the max value for that cut.Dry run it you will get it.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.