I’m not sure about the base cases that i’ve considered regarding the above problem, So i just want to confirm the base cases are correct or not?
// base case 1/
if(n == 0){
return;
}
if(n < 4){
return;
}
About base cases of the tiling problem
@archit_18 sorry for the late reply
here is the case associate with your query
Let “count(n)” be the count of ways to place tiles on a “n x 4” grid, following two cases arise when we place the first tile.
Place the first tile horizontally : If we place first tile horizontally, the problem reduces to “count(n-1)”
Place the first tile vertically : If we place first tile vertically, then we must place 3 more tiles vertically. So the problem reduces to “count(n-4)”
Therefore, count(n) can be written as below.
count(n) = 1 if n = 1 or n = 2 or n = 3
count(n) = 2 if n = 4
count(n) = count(n-1) + count(n-4)
Hey Archit,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.