GATE | GATE CS 2008 | Question 78
Let xn denote the number of binary strings of length n that contain noconsecutive 0s. Which of the following recurrences does Xn satisfy?
(A) A
(B) B
(C) C
(D) D
Answer: (D)
Explanation:
- For n = 1 i.e. binary strings of length 1, strings are ‘0’, ‘1’.
So, X1 = 2
- For n = 2 i.e. binary strings of length 2, strings are ’01’ , ’10’ , ’11’.
(here string ’00’ will be rejected because it has consecutive zeros).
So, X2 = 3
- For n = 3 i.e. binary strings of length 3, strings are ‘010’ , ‘011’ , ‘101’ , ‘110’ , ‘111’ .
0 01 (rejected)
0 10
0 11
1 01
1 10
1 11
So, X3 = 5
This shows that X3 = X2 + X1
Therefore, X(n) = X(n – 1) + X(n – 2)
Please comment below if you find anything wrong in the above post.
Quiz of this Question
Last Updated :
28 Jun, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...