Computer Sciences > Gate 2017 Set-2 > Grammer
Identity the language generated by following grammar where S is the start variable.

S --> XY
X --> aX | a
Y --> aYb | ∈
A
{am bn| m>=n, n>0 }
B
{am bn| m>=n, n>=0 }
C
{am bn | m>n, n>=0 }
D
{am bn| m>n, n>0 }

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

Which one of the following grammars is free from left recursion?
#87 MCQ
Which of the following languages is generated by the given grammar? S → aS|bS| ε
#134 MCQ
Consider the following grammar over the alphabet {a,b,c} given below, S and T are non-terminals. G1: S-->aSb|T T--> cT|∈ G2: S-->bSa|T T--> cT|∈ The language...
#179 MCQ

Related Topics

grammar theory GATE 2017 computer science gate language grammar a^n b^n problem m>n condition computer science gate questions

Unique Visitor Count

Total Unique Visitors

Loading......