-
Language L1 is defined by the grammar: S1 → aS1 b | ε
Language L2 is defined by the grammar: S2 → abS2 | ε
Consider the following statements:
P : L1 is regular
Q : L2 is regular
Which one of the following is TRUE?
-
- Both P and Q are true
- P is true and Q is false
- P is false and Q is true
- Both P and Q are false
- Both P and Q are true
Correct Option: C
L1 has the property that no. of a’s should be equal to no. of b’s in a string, and all a’s should precede all b’s. Hence extra memory will be required to check this property of a string (Finite Automata can't be built for this type of language). Hence this is not regular language. Therefore P is False. L2 has the property that no. of a’s should be equal to no. of b’s, but order of a’s and b’s is different here, it is (ab)*, which will require no extra memory to be accepted. (Finite Automata can be built for this language). Hence L2 is regular language. Therefore Q is True.