Skip to content
Related Articles

Related Articles

Improve Article

UGC-NET | UGC NET CS 2016 Aug – III | Question 22

  • Last Updated : 08 Jun, 2020

The regular grammar for the language L = {anbm | n + m is even} is given by
(A) S → S1 | S2
S1 → a S1| A1
A1 → b A1| λ
S2 → aaS2| A2
A2 → b A2| λ
(B) S → S1 | S2
S1 → a S1| aA1
S2 → aaS2| A2
A1 → b A1| λ
A2 → b A2| λ
(C) S → S1 | S2
S1 → aaa S1| aA1
S2 → aaS2| A2
A1 → b A1| λ
A2 → b A2| λ
(D) S → S1 | S2
S1 → aa S1| A1
S2 → aaS2| A2
A1 → bb A1| λ
A2 → bb A2| λ


Answer: (D)

Explanation: Given, language,

L = {a^n b^m | n + m is even} 

Here m+n should be even for this either m, n must be even or m, n must be odd.

Now we need to generate string as { $,ab, aa , bb,abbb, aaab,aabb,…….} for this grammar should be,

S = S1 | S2 
S1 = aa S1| A1 

Here, given production rules A1 derives even number of b’s so we have not problem, S1 also derives even number of a’s.

S2 = aaS2| A2

In this production A2 also derives odd number of b’s and A2 will have even number of a’s and b’s.



A1 = bb A1| λ 

This production also derives even number of b’s.

A2 = bb A2| λ 

This derives odd number of b’s all are fulfill the given condition of given language.

So, option (D) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :