Consider the following statements about the context free grammar
- is ambiguous
- produces all strings with equal number of ’s and ’s
- can be accepted by a deterministic PDA.
Which combination below expresses all the true statements about ?
View worked solution
Answer: B
To determine the correct statement(s), let us analyze each statement individually:
Statement I: is ambiguous
- A grammar is ambiguous if there exists at least one string in its language that has more than one leftmost derivation (or parse tree).
- Consider the string . We can derive it in multiple ways:
- Derivation 1:
- Derivation 2:
- Since the string has multiple distinct leftmost derivations, the grammar is ambiguous. Thus, Statement I is TRUE.
Statement II: produces all strings with equal number of ’s and ’s
- The production rules of are .
- Every non-empty terminal string generated by this grammar must be formed by concatenating the blocks and . Thus, the language generated is .
- Consider the string . It has an equal number of 's and 's, but it cannot be generated by because any string in must start with either or .
- Since , Statement II is FALSE.
Statement III: can be accepted by a deterministic PDA
- The language is a regular language because it can be represented by a regular expression.
- Every regular language can be accepted by a Deterministic Finite Automaton (DFA).
- Since any language accepted by a DFA can also be accepted by a Deterministic Pushdown Automaton (DPDA) by simply not using the stack, is accepted by a deterministic PDA. Thus, Statement III is TRUE.
Therefore, only statements I and III are true.
Free practice · Your answers on this page are not saved.
