Which of the following definitions generates the same language as L, where L =…
2012
Which of the following definitions generates the same language as L, where
L = { WWᴿ | W ∈ {a, b}* }
- A.
S → aSb | bSa | ε
- B.
S → aSa | bSb | ε
- C.
S → aSb | bSa | aSa | bSb | ε
- D.
S → aSb | bSa | aSa | bSb
Attempted by 12 students.
Show answer & explanation
Correct answer: B
The language L consists of even-length palindromes over {a, b}. The grammar S → aSa | bSb | ε correctly generates this by recursively adding matching characters around a center until the empty string is reached. Other options fail to enforce the palindrome structure or miss required cases like the empty string.
A video solution is available for this question — log in and enroll to watch it.