ProgrammingHardGATE CS · Campus placements
The number of ways to tile a 2 x 6 board with 2 x 1 dominoes equals the number of binary tilings given by T(n) = T(n-1) + T(n-2) with T(1) = 1 and T(2) = 2. What is T(6)?
- A. 8
- B. 13
- C. 21
- D. 12
Correct answer: B. 13
The values are T(1) = 1, T(2) = 2, T(3) = 3, T(4) = 5, T(5) = 8, T(6) = 13. A loop computes this in O(n) time and O(1) space, while naive recursion repeats work.
More C Programming questions
- Intervals (1,4), (2,3) and (3,5) are stored as pairs in an array and qsort sorts them ascending by their second value. Which pair comes…
- Which of these statements are well defined by the C standard? I. uint8t x = 255; x = x + 1; leaves x equal to 0. II. int a = INTMAX; a + 1…
- What is the sum of the decimal digits of 2^20 = 1048576?
- uint16t a = 40000, b = 40000; uint32t s = a + b; What is s?
- uint32t x = 0x80000001u; x = (x << 1) | (x >> 31); What is x?
- unsigned char c = 0x7F; c = c 2 + 2; What is c?