Skip to content
Official PYQ · 2026

GATE CS 2026 Set 2 Q38 — Regular and Context-free Languages

Explain with AI

Let Σ={a,b,c,d}\Sigma=\{a, b, c, d\} and let L={aibjckdℓ∣i,j,k,ℓ≥0}L=\left\{a^{i} b^{j} c^{k} d^{\ell} \mid i, j, k, \ell \geq 0\right\}.

Which of the following constraints ensure(s) that the language LL is context-free?

Select all correct options
View worked solution

Answer: A;C;D

To determine which constraints ensure that L={aibjckdℓ∣i,j,k,ℓ≥0}L = \{a^{i} b^{j} c^{k} d^{\ell} \mid i, j, k, \ell \geq 0\} is a context-free language (CFL), we analyze the dependencies between the symbol counts:

  • Option A (i+k=j+ℓi+k=j+\ell): This relation can be rewritten as i−j=ℓ−ki - j = \ell - k. We can construct a Pushdown Automaton (PDA) using a single stack to keep track of the difference. Alternatively, we can partition this into two context-free cases: i≥ji \ge j (which yields strings of the form amajbjckdkdma^m a^j b^j c^k d^k d^m) and i<ji < j (yielding aibibmcmcℓdℓa^i b^i b^m c^m c^\ell d^\ell). Both cases are context-free, so their union is also a CFL.
  • Option B (i=ki=k and j=ℓj=\ell): This requires matching aa's with cc's, and bb's with dd's. These are cross-serial dependencies (a↔ca \leftrightarrow c and b↔db \leftrightarrow d). A PDA cannot handle overlapping matches, making this language non-context-free.
  • Option C (i=ℓi=\ell and j=kj=k): This requires matching the outermost symbols (aa with dd) and the innermost symbols (bb with cc). These are nested dependencies, which perfectly match the LIFO structure of a stack. The language is generated by the CFG: S→aSd∣TS \to a S d \mid T T→bTc∣ϵT \to b T c \mid \epsilon Thus, it is a CFL.
  • Option D (i+j=k+ℓi+j=k+\ell): Here, the total number of prefix symbols (aa and bb) must equal the total number of suffix symbols (cc and dd). A PDA can simply push all aa's and bb's onto the stack, and then pop one symbol for each incoming cc and dd. Since a PDA can accept this language, it is a CFL.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions