Skip to content
Official PYQ · 2015

GATE CS 2015 Set 1 Q49 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Let an_{n} represent the number of bit strings of length n containing two consecutive 11s. What is the recurrence relation for ana_{n}?

Choose one option
View worked solution

Answer: A

To find the recurrence relation for ana_n, the number of bit strings of length nn containing two consecutive 11s, we can partition the set of valid strings of length nn based on their starting bits:

  1. Case 1: The string starts with 0
    The remaining n−1n-1 bits must contain two consecutive 11s.
    Number of such strings = an−1a_{n-1}
  2. Case 2: The string starts with 10
    The remaining n−2n-2 bits must contain two consecutive 11s.
    Number of such strings = an−2a_{n-2}
  3. Case 3: The string starts with 11
    Since we already have two consecutive 11s at the beginning, the remaining n−2n-2 bits can be any arbitrary bit string of length n−2n-2.
    Number of such strings = 2n−22^{n-2}

Since these three cases are mutually exclusive and collectively cover all valid strings of length nn, we sum them up to get the recurrence relation:

an=an−1+an−2+2n−2a_n = a_{n-1} + a_{n-2} + 2^{n-2}

This matches Option A.

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

Published
Report a correction
Keep exploringMore Asymptotic Worst Case Time and Space Complexity questions