Machine-translated by Google. Questions are authored in English.
Top

Discussion

Language \(L_{1}\) is defined by the grammar: \(S_{1} \rightarrow aS_{1}b \mid \varepsilon\)
Language \(L_{2}\) is defined by the grammar: \(S_{2} \rightarrow abS_{2} \mid \varepsilon\)

Consider the following statements:

\(P\): \(L_{1}\) is regular
\(Q\): \(L_{2}\) is regular

Which one of the following is TRUE?

  • A.Both \(P\) and \(Q\) are true
  • B.\(P\) is true and \(Q\) is false
  • C.\(P\) is false and \(Q\) is true
  • D.Both \(P\) and \(Q\) are false

Answer: C

P is false and Q is true.

\(S_{1} \rightarrow aS_{1}b \mid \varepsilon\) generates \(L_{1} = \{a^{n}b^{n} : n \ge 0\}\). Recognising it needs to count the a’s to match the b’s, and the pumping lemma shows it is not regular, so P is false.

\(S_{2} \rightarrow abS_{2} \mid \varepsilon\) generates \(L_{2} = (ab)^{*}\), any number of repetitions of the string ab. It is a right-linear grammar, and the regular expression \((ab)^{*}\) describes it, so Q is true.

Options calling \(L_{1}\) regular, or \(L_{2}\) non-regular, are therefore wrong.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.