Tiling problem recursion

not getting approach
if n==m then there will be 2 ways
if n<m then there will 1 way
else recursive case

hello @guptashubham210a

  • A tile can be either place vertically,meaning it will only occupy a cell of width 1 and a complete hieght of M. Or,
  • You can place M tiles horizontally one over the other if there is enough width left.

for n==m we can either place vertically or horizontally thats why there r 2 ways.
for n<m we can only place all tiles vertically thats why there is only 1 ways.

for remaining cases u just have to solve it recursively

I am not getting recursive cases only

it will be
f(n,m)=f(n-1,m) (when we place one tile horizontally) + f(n-m,m) (when we place m tile vertically)

thats why we r getting this recurrence
f(n,m)=f(n-1,m) + f(n-m,m)

why n-m? for 2nd call

when we will put m tile vertically then we will left with dimension n-m right?

got it.Thanks alloot

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.