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
- Which of the following statements are correct? 1. The first three-address instruction in the intermediate code is a leader. 2. The instruct…
- Which of the following are correct for regular expressions? a. φ + L = L + φ = L b. εL = Lε = L c. φL = Lφ = φ d. φL = Lφ = L Choose the co…
- Match the following based on the lengths of strings in the language accepted (using the brute-force method of parsing). Choose the correct…
- What is the safest order for simplifying a context-free grammar?
- What is the move in the cell numbered M1 of the table?
- What is the move in the cell numbered M2 of the table?