GATE Computer ScienceModerateGATE CSE · ISRO
Consider the grammar S → aSa | bSb | a | b | ε. How many strings of length exactly 7 does it generate?
- A. 32
- B. 8
- C. 16
- D. 24
Correct answer: C. 16
The grammar generates all palindromes over {a, b}; a palindrome of length 7 is fixed by its first 4 symbols, giving 2⁴ = 16.
More Theory of Computation questions
- Let L = { w ∈ {a, b} : the number of a's is divisible by 4 and w contains bb as a substring }. How many states does the minimal complete…
- A DFA reads 12-bit strings (MSB first) and accepts exactly those whose binary value is divisible by 7 (the all-zeros string included). How…
- Which one of the following languages over {0, 1} is regular?
- Let L = { w ∈ {a, b} : (na(w) − 2·nb(w)) mod 6 ∈ {0, 3} }, where na and nb count the a's and b's. How many states does the minimal…
- Let L = { w ∈ {a, b} : (2·na(w) + 4·nb(w)) mod 6 = 2 }. How many strings of length exactly 7 belong to L?
- A DFA reads ternary numerals over {0, 1, 2}, most significant digit first (leading zeros allowed; ε has value 0 and is accepted), and…