MSQ · 2 marks · Context Free Languages

GATE CS 2026 CS-1 — Q52

Consider the following context-free grammar GG.

S→abaABAbbaS \to abaABAbba
A→aaBBAIn∣bBabaaA \to aaBBAIn \mid bBabaa
B→aBb∣abB \to aBb \mid ab

In the above grammar, SS is the start symbol, aa and bb are terminal symbols, and AA and BB are non-terminal symbols.

Let L(G)L(G) be the language generated by the grammar GG. For a string s∈L(G)s \in L(G), let n1(s)n_1(s) be the number of aa’s in ss and n2(s)n_2(s) be the number of bb’s in ss.

Which of the following statements is/are true?
Select all correct options