GATE / CS ARCHIVE

GATE CSE 2015 SET 1 / QUESTION 45

GATE CSE 2015 Set 1 Q45

Discrete Mathematics · Recurrences & Generating Functions · Full GATE CSE 2015 Set 1 paper

GATE 2015 Set 1, Q45 2 marks · MCQ
Report issue

Recurrences & Generating Functions

Question 45, GATE 2015: Let a_n count n-bit strings containing two consecutive 1s. Which recurrence gives a_n? A a_(n−2)+a_(n−1)+2^(n−2); B a_(n−2)+2a_(n−1)+2^(n−2); C 2a_(n−2)+a_(n−1)+2^(n−2); D 2a_(n−2)+2a_(n−1)+2^(n−2).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Partition strings into mutually exclusive initial patterns 0,10,11. A leading 0 leaves a suffix of length n−1 that must contain 11. A leading 10 leaves length n−2 with the same requirement. A leading 11 already satisfies it, so all 2n−2 suffixes qualify. This gives A for n≥2 with a0=a1=0; as a check, a2=1 and a3=3.

Solution: Partition valid n-bit strings by prefixes 0, 10, 11. The first class contributes a(n−1), the second a(n−2), and the third has arbitrary remaining n−2 bits, contributing 2n−2. Hence a(n)=a(n−1)+a(n−2)+2n−2, A.

Original paper, page 17 · Answer key