Consider the context-free grammar below
where and are non-terminals, and and are terminal symbols. The starting non-terminal is .
Which one of the following statements is
View worked solution
Answer: B
To find the language generated by the grammar , we analyze the non-terminals step-by-step.
Step 1: Analyze the language generated by
The production rules for are:
Any derivation from must terminate with either or . We can prepend any number of 's and append any number of 's. Thus, generates all strings of the form where (i.e., at least one terminal is present, and all 's precede all 's).
Step 2: Analyze the language generated by
The production rules for are:
This means wraps strings from with an equal number of 's on the left and 's on the right:
Substituting (where ):
Let and . Since and , we have .
Conversely, for any with , we can simply choose , which yields and (where ). Thus, all such strings are generated:
Since this language is regular and matches option B, the correct statement is B.
Free practice · Your answers on this page are not saved.
