i did’nt get what exactly being done in bottom up approach.can anyone explain it in detail
Rod cutting Bottom Up aproach
if are asking in general then this is best way to differentiate b/w top down and bottom up
- Bottom Up - I’m going to learn programming. Then, I will start practicing. Then, I will start taking part in contests. Then, I’ll practice even more and try to improve. After working hard like crazy, I’ll be an amazing coder.
- Top Down - I will be an amazing coder. How? I will work hard like crazy. How? I’ll practice more and try to improve. How? I’ll start taking part in contests. Then? I’ll practicing. How? I’m going to learn programming.
and in context to problem
this is happening
consider rod of length i
for
(i = 1; i<=n; i++)
{
divide rod of length i into two rods of length j and i-j each and tak maximum
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;
}
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.