Question
Let represent the number of bit strings of length containing two consecutive 1s. What is the recurrence relation for ?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2015 answer key
Solution
Derive the recurrence relation by partitioning bit strings of length n based on their ending bit patterns.
Let denote the number of bit strings of length containing two consecutive 1s.
We partition any valid string of length into mutually exclusive cases based on its suffix:
- Ends in 0: The last bit is 0, so the first bits must contain two consecutive 1s. There are such strings.
- Ends in 01: The last two bits are 01, so the first bits must contain two consecutive 1s. There are such strings.
- Ends in 11: The last two bits are 11. Since this suffix already provides two consecutive 1s, the prefix of length can be ANY arbitrary bit string. The number of arbitrary bit strings of length is .
These three cases are mutually exclusive and collectively cover all valid bit strings of length .
Summing the counts gives the recurrence relation:
This matches option A.
A
Double-counting strings by adding 2^(n-2) to overlapping subcases.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2015 Computer Science and Information Technology (CS) Session 1
- Question
- 59 of 65, printed as CS Q.49
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.