GATE / CS ARCHIVE

SIMILAR QUESTIONS / DISCRETE MATHEMATICS

Split by final symbol to count strings with no adjacent selected symbols

3 questions solved the same way, newest first. Back to Discrete Mathematics

1 mark · MCQ
Report issue

Asked again GATE 2008, Q78 (same question)

Recurrences & Generating Functions

Question 2, GATE 2016: Let a_n count length-n binary strings with no consecutive 1s. Which recurrence holds? 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).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Partition valid n-bit strings by their last symbol. Those ending 0 append 0 to any valid (n−1)-bit string. Those ending 1 must end 01 and append 01 to a valid (n−2)-bit string. Hence an=an−1+an−2, B, with a0=1, a1=2.

The two cases must be disjoint and exhaustive. For n≥2, a valid string ends either in 0, or in 01; the latter is forced because a final 1 cannot follow another 1. Removing those suffixes gives arbitrary valid shorter strings and is reversible, so there is neither overcounting nor omission. For example a2=3 corresponds to 00,01,10, matching a1+a0=2+1. Initial values accompany the recurrence even though only the recurrence is requested.

Original paper, page 4 · Answer key

2 marks · MCQ
Report issue

Asked again GATE 2016 Set 1, Q2 (same question)

Counting strings with no consecutive zeros

Recurrences & Generating Functions

Question 78, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. Which recurrence does it satisfy?

(A) xₙ=2xₙ₋₁
(B) xₙ=x⌊ₙ/₂⌋+1
(C) xₙ=x⌊ₙ/₂⌋+n
(D) xₙ=xₙ₋₁+xₙ₋₂
Question 78, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. Which recurrence does it satisfy?

(A) xₙ=2xₙ₋₁
(B) xₙ=x⌊ₙ/₂⌋+1
(C) xₙ=x⌊ₙ/₂⌋+n
(D) xₙ=xₙ₋₁+xₙ₋₂
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Divide valid strings of length n≥2 by their first bit. A leading 1 can be followed by any valid length-(n−1) string.
2. A leading 0 must be followed by 1, leaving any valid length-(n−2) suffix. These two groups cannot overlap and cover every valid string.
3. Add their counts: xₙ=xₙ₋₁+xₙ₋₂, D. Initial values are x₀=1 and x₁=2, which are essential for numerical evaluation.

Original paper, page 17

2 marks · MCQ
Report issue

Length-five strings with no consecutive zeros

Combinatorics & Counting

Question 79, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. What is x₅?

(A) 5
(B) 7
(C) 8
(D) 16
Question 79, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. What is x₅?

(A) 5
(B) 7
(C) 8
(D) 16
Question 79, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. What is x₅?

(A) 5
(B) 7
(C) 8
(D) 16
Tap to enlarge
Your answer
Answer & solution

Answer: 13; no listed option (no official key was published)

1. The initial counts are x0=1 for the empty string and x1=2 for 0 and 1. The recurrence from Q78 gives x2=3, x3=5, x4=8 and x5=13.
2. Independently, count by the number of nonadjacent zeros: binomial(6,0)+binomial(5,1)+binomial(4,2)+binomial(3,3)=1+5+6+1=13. The scan lists 5,7,8,16; none is correct.
3. Do not use Fibonacci seeds 1,1, which count the wrong objects.

Original paper, page 17