All mock tests are FREE till 31 December — register to save your progress
Unit 8 · Theory of Computation and Compilers Paper 2 CS · December 2022 Shift 2

Which of the following is (are) correct about the regular expression a a* b b* c c* d d*?
1. The language for the given expression is L = {anbncmdm | n ≥ 1, m ≥ 1} ∪ {anbmcmdn | n ≥ 1, m ≥ 1}
2. The context-free grammar for the given expression is:
S → AB | C
A → aAb | ab
B → cBd | cd
C → aCd | aDd
D → bDc | bc
3. The language generated by this expression is an equal number of a's, followed by an equal number of b's, followed by an equal number of c's, followed by an equal number of d's.
Choose the correct answer from the options given below:

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. Both 1 and 2 are correct

Explanation

The grammar in 2 generates exactly the language in 1 (S → AB gives anbncmdm; S → C gives anbmcmdn). Statement 3 (all four counts equal) is wrong. The official key takes 1 and 2 as correct, although the expression as printed literally denotes a+b+c+d+.

More Theory of Computation and Compilers questions