📜  门| GATE-CS-2003 |第 90 题

📅  最后修改于: 2021-09-27 05:59:24             🧑  作者: Mango

令 G = ({S}, {a, b} R, S) 是一个上下文无关文法,其中规则集 R 是
S → a S b | SS | ε
下面哪个描述是正确的?
(A) G 没有歧义
(B)存在 x, y, ∈ L (G) 使得 xy ∉ L(G)
(C)存在接受 L(G) 的确定性下推自动机
(D)我们可以找到一个接受 L(G) 的确定性有限状态自动机答案: (C)
解释:

An ambiguous grammar can be converted to unambiguous one.

Here we can get grammar in partial GNF form as
S -> ab | abS | aSb | aSbS

We can convert this into GNF too but no need for PDA reasoning
so, above grammar is not a ambiguous thus a definite PDA possible

Trick for this is but just deriving 3-4 strings from grammar, we 
can easily understand its (anbn)* above 
expression anbn is in CFL thus closure of DCFG is a DCFG
i.e., you can get L = {ε, ab, abab, aabb, aabbab, abaabb, 
ababab,......}
PDA will push "a" until "b" is read, start popping "a" for the "b" read.

If "a" is read again from the tape then push only when stack is empty 
else terminate.

Repeat this until string is read.

Remember fastest way to get answer is by elimination other options.

这个问题的测验