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? 1. The language for the given expression is L = {aⁿbⁿcᵐdᵐ | n ≥ 1, m ≥ 1} ∪ {aⁿbᵐcᵐdⁿ | n ≥ 1, m ≥ 1}. 2. A context-free grammar for it is S → AB | C, A → aAb | ab, B → cBd | cd, C → aCd | aDd, D → bDc | bc. 3. The language has equal numbers of a's, b's, c's and d's in that order.

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 statement 2 generates exactly {aⁿbⁿcᵐdᵐ} (via AB) ∪ {aⁿbᵐcᵐdⁿ} (via C). Statement 3 is false: the counts of a and c (or a and b) need not be equal.

Note: no option is fully correct; the official key (C) is shown. As written, a a* b b* c c* d d* denotes a⁺b⁺c⁺d⁺, a regular language, so statement 1 is false. The official key treats statements 1 and 2 as describing {aⁿbⁿcᵐdᵐ} ∪ {aⁿbᵐcᵐdⁿ}.

More Theory of Computation and Compilers questions