GATE Computer ScienceHardGATE CSE
The grammar S → SS | a | b is ambiguous. How many distinct parse trees does it give for the string ababa?
- A. 5
- B. 10
- C. 24
- D. 14
Correct answer: D. 14
Parse trees correspond to full binary bracketings of 5 leaves: Catalan(4) = 14.
More Theory of Computation questions
- How many strings of length 8 does the grammar S → aSb | bSa | SS | ε generate?
- Consider these statements. I. Deterministic context-free languages are closed under complementation. II. Deterministic context-free…
- For a Turing machine M given as input, how many of these properties are undecidable? (a) L(M) = ∅ (b) M has at least 5 states (c) L(M)…
- Which of the following languages over {0, 1} is regular?
- A single-tape TM (blank B) starts in q0 at the leftmost symbol of a binary string. Rules: δ(q0,0) = (q0,0,R); δ(q0,1) = (q0,1,R); δ(q0,B)…
- How many strings of length 10 over {a, b} have no three consecutive equal symbols (neither aaa nor bbb)?