sir i am not able to understand the solution given in video
please help
Cant understand cell mitosis solution
Hey @bhavyarocks19 let me try to explain how we are computing the costs.
Remember x<=y<=z , so we will always favour multiplication>addition>subtraction.
Say we are trying to reach D.
Case 1: when D is odd, Now there are only 2 ways to reach D either from cell D+1 or cell D-1. We cannot directly reach D by performing the multiplication step. Now I expect the calculation for this step of reaching from D+1 was clear to you.
Case 2: when D is even, Now the possibility of reaching D from D+1 to be the best solution is ruled out.
Let me give a simple proof.
For reaching D+1,you must have used D+2(remember D+1 is odd) and lets say D+2 is a power of 2 and cost of doubling was 0, So only cost you had to pay to reach D+1 was z . So for reaching D from D+1 is 2z. Now we can always reach D in way better than 2z, hence this option is ruled out.
Therefore we only use the remaining 2 options to reach D.
I hope the approach is clear now.