Data Structures & AlgorithmsModerateGATE CS · TCS NQT

In how many ways can a 2 × 9 board be tiled exactly with 2 × 1 dominoes (placed vertically) and 2 × 2 squares, with no overlaps and no gaps? Rotations of a piece count as different placements only when they are different positions.

  1. A. 34
  2. B. 55
  3. C. 60
  4. D. 512

Correct answer: B. 55

Look at the leftmost column: it is either one vertical domino (leaving a 2 × (n−1) board) or half of a 2 × 2 square (leaving 2 × (n−2)). That gives the Fibonacci recurrence f(n) = f(n−1) + f(n−2).

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic