Question

Construct a PDA for the context free grammar: S → AxA | By | zC A...

Construct a PDA for the context free grammar: S → AxA | By | zC

A → B | a

B → C | b

C → SS | c | ε

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:------------

Algorithm to find PDA corresponding to a given CFG:------------
Input − A CFG, G = (V, T, P, S)
Output − Equivalent PDA, P = (Q, ∑, S, δ, q0, I, F)

Step 1 − Convert the productions of the CFG into GNF.

Step 2 − The PDA will have only one state {q}.

Step 3 − The start symbol of CFG will be the start symbol in the PDA.

Step 4 − All non-terminals of the CFG will be the stack symbols of the PDA and all the terminals of the CFG will be the input symbols of the PDA.

Step 5 − For each production in the form A → aX where a is terminal and A, X are combination of terminal and non-terminals, make a transition δ (q, a, A).

Given, Problem:--------------
Construct a PDA from the following CFG.
G = ({S, A,B,C}, {a, b, c, x, y, z}, P, S)
where the productions are −

S → AxA | By | zC

A → B | a

B → C | b

C → SS | c | ε

Solution:--------
Let the equivalent PDA,

P = ({q}, {a, b, c, x, y, z}, {a, b, c, x, y, z, A, B, C, S}, δ, q, S)

where δ −

δ(q, ε , S) = { (q, AxA), (q, By), (q, zC) }

δ(q, ε , A) = { (q, B), (q, a) }

δ(q, ε , B) = { (q, C), (q, b) }

δ(q, ε , C) = { (q,SS), (q, c), (q, ε) }

δ(q, a, a) = { (q, ε ) }

δ(q, b, b) = { (q, ε ) }\

δ(q, c, c) = { (q, ε ) }

δ(q, x, x) = { (q, ε ) }

δ(q, y, y) = { (q, ε ) }

δ(q, z, z) = { (q, ε ) }

Add a comment
Know the answer?
Add Answer to:
Construct a PDA for the context free grammar: S → AxA | By | zC A...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT