How to solve this question using RECURSION ONLY
I have written this code but it’s not working
Advanced DP CELL MITOSIS
define your function as generate(int n,int x,int y,int z) where n is the value that you want to achieve.
base case: if(n<=1) return 0
recursion:
if n is even:
mincost=min(mincost,x+generate(n/2,x,y,z));
mincost=min(mincost,y+generate(n-1,x,y,z));
if n is odd:
mincost=min(mincost,x+z + generate((n+1)/2 ,x,y,z));
mincost=min(mincost,y+generate(n-1,x,y,z));
The same approach was discussed in the video. You can memoize if you want to build dp.
Let me know if any part of the suggestion is not clear to you.