Does the relation f(n)=f(n-1)+f(n-4) gives the wrong answer for n=4?
Doubt in recursion relation
No…you will have to make the base cases accordingly for the relation to work perfectly.
Base cases must be like this:
if (n < 1)
return 0;//Because tiling not possible
if (n < 4)
return 1;//Because now you have only 1 way to tile and that is to tile vertically
if (n == 4)
return 2; //Because now you have 2 ways- either tile all vertically or tile all horizontally
thanks a lot! my doubt has been resolved