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

Which of the following Grammars is/are only Context Free?

Figure

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

Show answer & explanation

Correct answer: B. C, D Only

Explanation

Grammar A has a non-terminal string (aS) on the left side, so it is not context-free. B (S→Ab, A→Sa|a) and E (S→Sb, A→Aa|ε) are purely left-linear, so they are regular grammars. C uses S→AS (two non-terminals on the right) and D mixes left-linear (S→Ab) and right-linear (S→aA) rules, so C and D are context-free grammars but not regular grammars.

More Theory of Computation and Compilers questions