Yes bhaiya. I have seen that content but still I didn’t get this doubt…
if dp[6] we are computing then, we should look for dp[5] and dp[4] but why not dp[7]?
Because, still we are computing for the odd index in the DP array at the end, so why can’t we include that odd condition when we are computing for even index i.e. dp[6]
Prateek Bhaiya narrated the idea that we can’t include dp[7] to compute dp[6] because dp[7] will take more operations than dp[4] and dp[5] and our task is to find minimum operations at the end.
But, I didn’t get the idea, how dp[7] will take more operation than dp[5] and dp[4] to compute dp[6]…?
Even Condition: when i is even
dp[i]=min( dp[i/2]+x , dp[i-1]+y )
Odd Condition: when i is odd
dp[i]=min( dp[i-1]+y , dp[i/2]+x+z )