X --> aX | a
Y --> aYb | ∈
Correct : G
Given:
Grammar with start symbol S:
S → XY
X → aX | a
Y → aYb | ∈
To find:
The language generated by this grammar.
Solution:
First, let me look at the variable X.
X produces either a or calls itself with an a, with no option to produce ∈.
So, X generates at least one a:
L(X) = {ak | k ≥ 1}
Now let me check the variable Y.
Y adds an a on the left and a b on the right, or it terminates with ∈.
So, Y generates an equal number of a's and b's, including the empty string:
L(Y) = {an bn | n ≥ 0}
Now, combining them through S → XY:
Any string derived from S has the form w = ak an bn = ak+n bn.
Let m be the total number of a's, so m = k + n.
Since k ≥ 1, we have m = k + n ≥ 1 + n, which means m > n.
Also, since Y can derive ∈, n can be 0, so n ≥ 0.
Putting these conditions together gives:
L(S) = {am bn | m > n, n ≥ 0}
This matches option C directly.
Answer: (C) {am bn | m>n, n>=0 }
Similar Questions
Total Unique Visitors