Tiling with Dominoes
Last updated
Last updated
Given a 3 x n board, find the number of ways to fill it with 2 x 1 dominoes.
Example 1 Following are all the 3 possible ways to fill up a 3 x 2 board.
Example 2 Here is one possible way of filling a 3 x 8 board. You have to find all the possible ways to do so. Examples :
Approach:
Defining Subproblems: At any point while filling the board, there are three possible states that the last column can be in:
Note: The following states are impossible to reach:
Finding Reccurences Note: Even though Bn and Cn are different states, they will be equal for same ‘n’. i.e Bn = Cn Hence, we only need to calculate one of them.
Calculating An:
Calculating Bn: