GATE Computer ScienceHardGATE CS

Which one of the following languages over the one-letter alphabet {a} is NOT context-free?

  1. A. { aⁿ : n is a perfect square }
  2. B. { aⁿ : n ≥ 8 and n ≡ 3 (mod 5) }
  3. C. { aⁿ : n ≡ 2 (mod 3) and (n ≤ 100 or n is even) }
  4. D. { aⁿ : n is divisible by 7 or by 11 }

Correct answer: A. { aⁿ : n is a perfect square }

By Parikh's theorem every context-free language over a one-letter alphabet is regular, so its length set is eventually periodic. The three other length sets are eventually periodic, while the gaps between successive squares keep growing.

More Theory of Computation questions

Exams that ask this topic