Related Articles

# GATE | GATE CS 2008 | Question 78

• Last Updated : 28 Jun, 2021

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

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

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up