Aug2016 cs Q22

0. The regular grammar for the language L = {anbm | n + m is even} is given by

  • Option : D
  • Explanation :
    Given, L = L = {anbm | n + m is even}
    For (n + m) to be even either n and m both are even or n and m both are odd.
    So, for n and m to be even, grammar is;
    S1 → aa S1| A1 
    A1 → bb A1| λ
    For n and m odd, grammar is:
    S2 → aaS2| aA2 
    A2 → bbA2| b
    Now, combine both; then resultant grammar is:
    S → S1 | S2 
    S1 → aa S1| A1 
    S2 → aaS2| aA2 
    A1 → bb A1| λ
    A2 → bb A2| b
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *