https://online.codingblocks.com/player/2831/content/378
This video: CPP- Recursion Tiling problem.
I am not getting how f(n)=f(n-1)+f(n-4);
Please explain it bit more.
Unable to understand explanation in video
First think about the possibilities of putting the tiles in the room (4 X N )
- one way is to put one tile in vertical manner then you will left with n-1 column of size 1 so no of ways will be f(n-1) if f(n) denotes the no of ways to put all tiles in box of N column
- second way is to put one tile horizontally , so if you did this then you can place horizontally only over first as you can not put it vertically , so this will be done in f(n-4) no of ways
Finally base case will be -->> if(n==1 or 2 or 3) return 1;
don’t you think your base case is wrong.for n==2 it will be 1 only because there will be only one way of arranging tiles(both the tiles will be vertical). for n==3 also it will be 1 but for n==4 it will be 2(all four tiles horizontal or vertical).
typed by mistake , it should be 1