Exams › GATE › Technical
Consider the following two languages over the alphabet {a, b, c}, where m and n are natural numbers.
L1 = {a^m b^m c^(m+n) | m, n ≥ 1}
L2 = {a^m bⁿ c^(m+n) | m, n ≥ 1}
Which ONE of the following statements is CORRECT?
- Both L1 and L2 are context-free languages.
- L1 is a context-free language but L2 is not a context-free language.
- L1 is not a context-free language but L2 is a context-free language.
- Neither L1 nor L2 are context-free languages.
Correct answer: Both L1 and L2 are context-free languages.
Solution
Both L1 and L2 can be generated by context-free grammars, as they can be expressed with rules that allow for the balanced counting of 'a's and 'b's while accommodating the unrestricted number of 'c's, which can be derived from the context-free language properties.
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →