GATE Computer ScienceHardGATE CS (PYQ pattern)
The following grammars all generate subsets of {a, b}*, with S as the start symbol. Exactly one of the four grammars is unambiguous; which one?
- A. S → A | B; A → aA | ε; B → bB | ε
- B. S → aSb | bS | ε
- C. S → SS | a
- D. S → aS | Sb | ab
Correct answer: B. S → aSb | bS | ε
Every string it generates has a unique parse tree; each other grammar has a string with two parse trees: "ε" in S → A | B; A → aA | ε; B → bB | ε; "aaa" in S → SS | a; "aabb" in S → aS | Sb | ab.
More Theory of Computation questions
- Parser generators reject ambiguous grammars. Consider these CFGs (start symbol S). Exactly one of the four grammars is ambiguous; which one?
- Each option is a CFG over {a, b} with start symbol S. Exactly one of the four grammars is ambiguous; which one?
- A PDA with start state q0, bottom symbol Z, input alphabet {a, b} and accepting state qf (acceptance by final state) has transitions…
- A PDA with start state q0 and bottom symbol Z accepts by EMPTY STACK. Its transitions (stack top written first) are: δ(q0, a, Z) = {(q0…
- A nondeterministic PDA (start q0, bottom symbol Z, final state qf, acceptance by final state) has the rules: in q0 it pushes A or B for…
- A DPDA has start state q0, bottom symbol Z, accepting state set {q0} (acceptance by final state after the whole input is read) and…