Skip to content

GATE CS 2016 Set 1 Q2 — Combinatorics: Counting, Recurrence Relations, Generating Functions

Explain with AI

Let ana_n be the number of nn-bit strings that do NOT contain two consecutive 1′s1's. Which one of the following is the recurrence relation for ana_n?

Choose one option
View worked solution

Answer: B

To find the recurrence relation for ana_n, the number of nn-bit strings that do not contain two consecutive 11's, we can analyze the possible endings of a valid nn-bit string:

  • Case 1: The string ends with 00.
    If the last bit is 00, the preceding n−1n-1 bits can be any valid string of length n−1n-1 that does not contain consecutive 11's. There are an−1a_{n-1} such strings.
  • Case 2: The string ends with 11.
    If the last bit is 11, the second-to-last bit must be 00 to avoid consecutive 11's (i.e., the string must end in 0101). The preceding n−2n-2 bits can be any valid string of length n−2n-2 that does not contain consecutive 11's. There are an−2a_{n-2} such strings.

Since these two cases are mutually exclusive and cover all valid nn-bit strings, we sum them to get the total number of strings:

an=an−1+an−2for n≥3a_n = a_{n-1} + a_{n-2} \quad \text{for } n \ge 3

Verification with small values:

  • For n=1n = 1, the valid strings are {0,1}\{0, 1\}, so a1=2a_1 = 2.
  • For n=2n = 2, the valid strings are {00,01,10}\{00, 01, 10\}, so a2=3a_2 = 3.
  • For n=3n = 3, the valid strings are {000,001,010,100,101}\{000, 001, 010, 100, 101\}, so a3=5a_3 = 5.

Using the recurrence relation: a3=a2+a1=3+2=5a_3 = a_2 + a_1 = 3 + 2 = 5, which matches our count.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Combinatorics: Counting, Recurrence Relations, Generating Functions questions