Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Theory of Computation
  • Context-free grammars
  • Easy

The language L={anbn:n≥0}L = \{a^nb^n : n \ge 0\} is

Context-Free Languages

Pick an option to check your answer.

  • Context-free: the grammar S→aSb∣εS \to aSb \mid \varepsilon generates exactly LL (and a PDA can push aa's and pop on bb's).
  • Not regular: by the pumping lemma, take apbpa^pb^p; pumping yy inside the first pp symbols changes only the number of aa's, giving a string outside LL.

Why not the others

  • regular — a finite automaton cannot count an unbounded number of aa's.
  • context-sensitive but not context-free — it is context-free; {anbncn}\{a^nb^nc^n\} is the classic context-sensitive example.
  • not recursively enumerable — every context-free language is decidable.

Report an error

GATE CS · Theory of Computation · Context-Free Languages