Consider the following grammars : G : S → aSb|bSa|aa 1 G : S → aSb|bSa|SS ∣ λ 2 G : S → aSb|bSa|SS ∣ a 3 G : S → aSb|bSa|SS|SSS|λ 4 Which of the following is correct w.r.t. the above grammars? G G
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. 2 and 4 are equivalent G G
Explanation
G2 generates all strings with equal numbers of a's and b's. G4 adds S → SSS, which G2 can already simulate with SS twice, so G2 and G4 are equivalent. G1 and G3 generate different sets (extra a's).
More Theory of Computation and Compilers questions
- Which grammar generates L = {aⁿbⁿ⁻³ | n > 2} over Σ = {a, b}?
- Consider the following grammar : S → 0A ∣ 0BB A → 00A ∣ λ B → 1B ∣ 11C C → B Which language does this grammar generate?
- Let Σ = {w, x} and T = {x, y, z}, with homomorphism h(x) = xzy and h(w) = zxyy. If L is denoted by r = (w + x*)(ww)*, then h(L) is denoted…
- Consider the following statements with respect L = {anbn ∣ n ≥ 0} to the language S : L2 1 is context free language S : Lk 2 is conext-free…
- Consider the following languages : L = {anbncm} ∪ {anbmcm}, n, m ≥ 0 1 L = {wwR ∣ w ∈ {a, b}*} 2 Where R represents reversible operation. W…
- Let G=(V, T, S, P) be any context-free grammar λ without any -productions or unit productions. Let K be the maximum number of symbols on th…