GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A DFA reads a binary number most-significant bit first (leading zeros allowed; the empty string counts as 0). How many states does the minimal complete DFA have for the multiples of 6, and for the multiples of 12?
- A. 6 and 12
- B. 4 and 5
- C. 4 and 6
- D. 6 and 5
Correct answer: B. 4 and 5
Track the value mod 3 and only as much of the tail as matters. For 6 the number must be ≡ 0 (mod 3) and end in 0; once the residue mod 3 is non-zero the last bit is irrelevant (more bits must come anyway), so the classes are: r = 0 ending in 0 (or empty), r = 0 ending in 1, r = 1, r = 2: 4. For 12 = 4·3 the r = 0 class splits by the tail (ends in 00 or empty, ends in a single 0, ends in 1): 3 + 2 = 5.
More Compiler Design questions
- The grammar S → S a b | S c | A S | x; A → A d | S y | z is transformed by the standard algorithm that removes (indirect and immediate)…
- For the code 1: i = 0; 2: s = 0; 3: L1: if i >= n goto L4; 4: t = a + i; 5: if t > m goto L2; 6: s = s + t; 7: goto L3; 8: L2: a = a - 1…
- For G: S → a B | a C d; B → b | ε; C → b c, which statements are true? I. G is LL(2). II. G is LL(3). III. G is LR(0). IV. G is SLR(1).
- Construct the LL(1) table of S → A B c | B d; A → a A | ε; B → b B | A. Which option lists exactly the multiply-defined cells?
- An ε-NFA over {a, b} has states 0–4, start state 0 and accepting state 3, with moves δ(0, a) = {1}, δ(1, b) = {2}, δ(2, a) = {0, 3}, δ(3…
- For the code 1: i = 0; 2: s = 0; 3: L1: if i >= n goto L4; 4: t = a + i; 5: if t > m goto L2; 6: s = s + t; 7: goto L3; 8: L2: a = a - 1…