GATE Computer ScienceHardGATE CS (PYQ pattern)
Each option is a CFG over {a, b} with start symbol S. Exactly one of the four grammars is ambiguous; which one?
- A. S → aSb | bS | ε
- B. S → aS | aSb | ε
- C. S → aSb | A; A → aA | ε
- D. S → aSa | bSb | a | b | ε
Correct answer: B. S → aS | aSb | ε
The string "aab" 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
- 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…
- A single-tape TM with blank B starts in q0 on the leftmost cell of the input 10111. Its rules (state, symbol) → (state, write, move) are…