Which of the following CFGs cannot be simulated by an FSM?

2021

Which of the following CFGs cannot be simulated by an FSM?

  1. A.

    S→Sa | b

  2. B.

    S→aSb | ab

  3. C.

    S→abX, X→cY, Y→d | aX

  4. D.

    S→Sb | a

  5. E.

    Question not attempted

Attempted by 31 students.

Show answer & explanation

Correct answer: B

To determine which CFG cannot be simulated by an FSM, we need to check whether the language generated by each CFG is regular or not. An FSM can only recognize regular languages. If a CFG generates a non-regular language, it cannot be simulated by an FSM.

Option A: S→Sa | b

This CFG generates strings of the form b, ba, baa, baaa, etc. This is equivalent to the regular expression b a*. Since this language is regular, it can be recognized by an FSM.

Option B: S→aSb | ab

This CFG generates strings of the form ab, aabb, aaabbb, etc. This is the language a^n b^n, which is not regular. It requires counting the number of a's and matching it with the number of b's, which cannot be done by an FSM. Therefore, this CFG cannot be simulated by an FSM.

Option C: S→abX, X→cY, Y→d | aX

This CFG generates strings starting with ab, followed by c, and then either d or a sequence of a's and c's. The structure is linear and does not require unbounded counting. The language is regular, so it can be recognized by an FSM.

Option D: S→Sb | a

This CFG generates strings of the form a, ab, abb, abbb, etc. This is equivalent to the regular expression a b*. Since this language is regular, it can be recognized by an FSM.

Option E: Question not attempted

This is not a valid CFG and does not represent a grammar. It is not a relevant choice for the question.

Therefore, the CFG that cannot be simulated by an FSM is Option B.

Explore the full course: Bpsc