GATE Computer ScienceHardGATE CS (PYQ pattern)

Consider L = { aⁿbⁿ : n ≥ 0 } ∪ { aⁿb²ⁿ : n ≥ 0 }. Which classification is correct?

  1. A. Regular
  2. B. Deterministic context-free
  3. C. Context-free, not deterministic
  4. D. Not context-free

Correct answer: C. Context-free, not deterministic

It is a union of two CFLs, so context-free. A DPDA would have to decide after the a's whether to expect n or 2n b's, which it cannot; the language is the standard example of a CFL that is not a DCFL.

More Theory of Computation questions

Exams that ask this topic