Professional Documents
Culture Documents
𝑆𝑆 → 𝐴𝐴𝐴𝐴
𝐴𝐴 → 𝑎𝑎𝑎𝑎 | Λ
𝐵𝐵 → 𝑎𝑎𝑎𝑎 | 𝑏𝑏𝑏𝑏 | Λ
Every derivation of a string in this grammar must begin with the production
𝑆𝑆 → 𝐴𝐴𝐴𝐴. Clearly, any string derivable from 𝐴𝐴 has only one derivation from 𝐴𝐴, and likewise
for 𝐵𝐵. Therefore, the grammar is unambiguous. True or false? Why?
False. The grammar is ambiguous because the string 𝑎𝑎𝑎𝑎 has two left most derivations as
shown below:
and
𝑆𝑆 ⇒ 𝐴𝐴𝐴𝐴 ⇒ 𝐵𝐵 ⇒ 𝑎𝑎𝑎𝑎
[5 Marks] A transition table is given below for a PDA with initial state 𝑞𝑞0 and accepting
state 𝑞𝑞3 . Describe in the language that is accepted.
OR
(𝑎𝑎 + 𝑏𝑏)𝑚𝑚 𝑎𝑎(𝑎𝑎 + 𝑏𝑏)∗ 𝑏𝑏(𝑎𝑎 + 𝑏𝑏)𝑚𝑚 + (𝑎𝑎 + 𝑏𝑏)𝑚𝑚 𝑏𝑏(𝑎𝑎 + 𝑏𝑏)∗ 𝑎𝑎(𝑎𝑎 + 𝑏𝑏)𝑚𝑚
Hence, the language comprises of the strings which have some middle substring that starts
and ends with different alphabets.