Machine-translated by Google. Questions are authored in English.
Top

Discussion

Let \(a_{n}\) be the number of \(n\)-bit strings that do NOT contain two consecutive 1s. Which one of the following is the recurrence relation for \(a_{n}\)?

  • A.\(a_{n} = a_{n-1} + 2a_{n-2}\)
  • B.\(a_{n} = a_{n-1} + a_{n-2}\)
  • C.\(a_{n} = 2a_{n-1} + a_{n-2}\)
  • D.\(a_{n} = 2a_{n-1} + 2a_{n-2}\)

Answer: B

The recurrence is \(a_{n} = a_{n-1} + a_{n-2}\).

Split the valid \(n\)-bit strings by their last bit. If it ends in 0, the first \(n-1\) bits can be any valid string: \(a_{n-1}\) ways. If it ends in 1, the bit before must be 0 (no two consecutive 1s), and the first \(n-2\) bits can be any valid string: \(a_{n-2}\) ways. Adding the cases gives the Fibonacci recurrence.

Check with small cases: \(a_{1} = 2\) (0, 1), \(a_{2} = 3\) (00, 01, 10), and \(a_{3} = 5\) = 3 + 2. The other recurrences overcount; for example \(a_{n-1} + 2a_{n-2}\) gives 7 for \(n = 3\).

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.