All mock tests are FREE till 31 December — register to save your progress

Consider the language L = {w ∈ {a, b, c}* : nₐ(w) + n_b(w) = n_c(w)}. L is

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. Context free but not linear

Explanation

A PDA can push for each a or b and pop for each c (with sign handling), so L is context-free. Because the symbols can occur in any order, L is not generated by a linear grammar (the keyed answer).

More Theory of Computation and Compilers questions