Question
Let be the number of -bit strings that do NOT contain two consecutive 1s. Which one of the following is the recurrence relation for ?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2016 answer key
Solution
Classify -bit valid strings by their last bit to set up the linear recurrence relation.
Let denote the number of -bit binary strings with no consecutive 1s.
Consider the final bit of any valid -bit string:
- If the string ends in 0, removing the final 0 leaves a valid -bit string with no consecutive 1s. There are such strings.
- If the string ends in 1, the preceding bit must be 0 (since consecutive 1s are forbidden). Thus the string must end in the suffix '01'. Removing this suffix leaves a valid -bit string with no consecutive 1s. There are such strings.
Since every valid string either ends in 0 or ends in 01, by the rule of sum:
B
Multiplying by 2, which would erroneously allow the preceding bit to be 1.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2016 Computer Science and Information Technology (CS) Session 1
- Question
- 12 of 65, printed as CS Q.2
- 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.