Project ForgeSign up free
Theory of Computation
Grammars, Turing Machines & Decidability
GATE 2018
Expert

Consider the following languages:

I. {aᵐbⁿcᵖdᵠ | m+p=n+q, where m,n,p,q≥0}
II. {aᵐbⁿcᵖdᵠ | m=n and p=q, where m,n,p,q≥0}
III. {aᵐbⁿcᵖdᵠ | m=n=p and p≠q, where m,n,p,q≥0}
IV. {aᵐbⁿcᵖdᵠ | mn=p+q, where m,n,p,q≥0}

Which of the languages above are context-free?

  • AI and IV only
  • I and II only
  • CII and III only
  • DII and IV only

Explanation

II is clearly CFL: it's the concatenation of two independent CFLs, aⁿbⁿ and cᵖdᵖ, and CFLs are closed under concatenation. I ({m+p=n+q}) is also context-free — a linear additive relation across the fixed-order blocks can be tracked with a single stack (pushing for a's/extra-b's and popping appropriately as the c/d blocks are read), using nondeterminism to guess which side has the 'excess'. III requires matching THREE quantities (m=n=p) simultaneously, which exceeds what a single-stack PDA can enforce — not context-free (like the classic aⁿbⁿcⁿ). IV involves a MULTIPLICATIVE relation (mn), which no CFL can express (stack-based counting is fundamentally additive) — not context-free. So I and II are context-free.

Source: GATE CS 2018 (2018)

This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.

Start revising free