Open In App

GATE | GATE-CS-2003 | Question 90

Let G = ({S}, {a, b} R, S) be a context free grammar where the rule set R is S → a S b | SS | ε Which of the following statements is true?

(A)



G is not ambiguous

(B)



There exist x, y, ∈ L (G) such that xy ∉ L(G)

(C)

There is a deterministic pushdown automaton that accepts L(G)

(D)

We can find a deterministic finite state automaton that accepts L(G)


Answer: (C)
Explanation:

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.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :