Let \(a_n\) represent the number of bit strings of length \(n\) containing two…

2015

Let \(a_n\) represent the number of bit strings of length \(n\) containing two consecutive 1s. What is the recurrence relation for \(a_n\) ?

Answer: A. \(a_{n - 2} + a_{n - 1} + 2^{n - 2}\)Key idea: partition all n-bit strings by their first one or two bits. If the first two bits are 11, the remaining n-2 bits can be anything, yielding 2^{n-2}…

  1. A.

    \(a_{n - 2} + a_{n - 1} + 2^{n - 2}\)

  2. B.

    \(a_{n - 2} + 2a_{n - 1} + 2^{n - 2}\)

  3. C.

    \(2a_{n - 2} + a_{n - 1} + 2^{n - 2}\)

  4. D.

    \(2a_{n - 2} + 2a_{n - 1} + 2^{n - 2}\)

Attempted by 1 students.

Show answer & explanation

Correct answer: A

Key idea: partition all n-bit strings by their first one or two bits.

  • If the first two bits are 11, the remaining n-2 bits can be anything, yielding 2^{n-2} strings that contain two consecutive 1s.

  • If the first bit is 0, then the last n-1 bits must contain two consecutive 1s, contributing a_{n-1} strings.

  • If the first two bits are 10, then the last n-2 bits must contain two consecutive 1s, contributing a_{n-2} strings.

These three cases are disjoint and cover all n-bit strings, so

a_n = a_{n-1} + a_{n-2} + 2^{n-2}.

Base cases:

  • a_0 = 0 (empty string contains no 11).

  • a_1 = 0 (strings of length 1 cannot contain 11).

  • a_2 = 1 (only the string 11 contains consecutive 1s).

Thus the recurrence and base cases fully determine a_n.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…