GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 29

Bounded final count imbalance

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2006 paper

GATE 2006, Q29 2 marks · MCQ
Report issue

Regular Expressions & Languages

Question 29, GATE 2006: For binary string s, let n₀(s),n₁(s) count zeros and ones. Which language is not regular?
Options:
(A) {s:n₀(s) is a three-digit prime}
(B) {s:for every prefix t of s, |n₀(t)−n₁(t)|≤2}
(C) {s:|n₀(s)−n₁(s)|≤4}
(D) {s:n₀(s) mod 7=0 and n₁(s) mod 5=0}
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. A is regular because the permitted zero counts are finitely many three-digit primes; count zeros up to the maximum with an overflow state. B tracks prefix imbalance in{−2,−1,0,1,2}, rejecting immediately outside that range.

2. D tracks zero count modulo 7 and one count modulo 5. C only bounds the final imbalance and allows arbitrarily large intermediate imbalance.

3. Intersect C with 0*1* and pump 0p1p: pumping a nonempty block of initial zeros sufficiently many times makes the final difference exceed 4. Hence C is not regular.

4. Teaching check: A bound on every prefix permits a finite-state machine to reject immediately when its imbalance leaves a fixed range. A bound only on the final string allows arbitrarily large positive imbalance followed by enough ones to cancel it. Tracking this unbounded debt cannot be done with finitely many states.

Original paper, page 4