GATE Computer ScienceHardGATE CS (PYQ pattern)
Parser generators reject ambiguous grammars. Consider these CFGs (start symbol S). Exactly one of the four grammars is ambiguous; which one?
- A. S → aSb | ε
- B. S → aSa | bSb | a | b | ε
- C. S → SaS | b
- D. S → aA | bB; A → aA | a | bB; B → bB | b
Correct answer: C. S → SaS | b
The string "babab" has 2 distinct parse trees under it. In each of the other grammars every string of length ≤ 8 has exactly one parse tree (and each is a standard unambiguous pattern).
More Theory of Computation questions
- 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…
- A nondeterministic PDA over {a, b, c} (acceptance by final state at the end of the input) guesses at the start whether to check #a = #b…