Practice free →
HomeGATE CSEcomputerscienceTheory of Computation › Which of the following languages is CONTEXT-FREE?

Which of the following languages is CONTEXT-FREE?

A$\{a^n b^n c^n \mid n \geq 0\}$
B$\{ww \mid w \in \{a,b\}^*\}$
C$\{a^i b^j c^k \mid i = j \text{ OR } j = k\}$
D$\{w \mid w \text{ has equal a's and b's and c's}\}$
Answer & Solution
Correct answer: C. $\{a^i b^j c^k \mid i = j \text{ OR } j = k\}$
1. Option C: $\{a^i b^j c^k \mid i = j \text{ OR } j = k\}$ is the UNION of two simpler languages: - $L_1 = \{a^n b^n c^k\}$ — CFL (PDA matches a's and b's, ignores c's) - $L_2 = \{a^k b^n c^n\}$ — CFL (PDA matches b's and c's, ignores a's) 2. CFLs are CLOSED under union: a PDA recognises $L_1 \cup L_2$ by nondeterministically picking which sub-language to verify. 3. So option C is CFL ✓. 4. Options A, B, D require matching THREE quantities simultaneously — beyond a single stack's capacity. All three are NOT context-free. 5. Notably: option C ($\text{i=j OR j=k}$, NON-intersection) IS context-free but $L_1 \cap L_2$ would NOT BE (matches both, requires all three equal). _Source: Jeff Erickson, "Models of Computation", §5.12 (CFL closure properties)._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions