GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 30

Binary numerical residue constraints

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

GATE 2006, Q30 2 marks · MCQ
Report issue

Regular Expressions & Languages

Question 30, GATE 2006: For a binary string s let d(s) be its numerical value, for example d(101)=5. Classify L={s:d(s) mod 5=2 and d(s) mod 7≠4}.
Options:
(A) Recursively enumerable but not recursive
(B) Recursive but not context-free
(C) Context-free but not regular
(D) Regular
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. A finite automaton stores the current binary value modulo 35. Reading bit b replaces residue r by(2r+b) mod35.

2. Accept precisely residues r with r mod5=2 and r mod7≠4. This recognizes the language, so it is regular, D; leading zeros do not affect the construction.

3. Teaching check: The joint modulus 35 suffices because both congruence tests depend only on the value modulo 35. Starting at residue zero, scan bits left to right and update r←(2r+b) mod 35. A 35-state DFA with appropriate accepting residues is a constructive regularity proof.

Original paper, page 4