CFG to PDA: December 2024

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CD-501 Theory of Computation December 2024 Solved Question Paper

Question

Explain the CFG-to-PDA conversion procedure and apply it to S→aABB | aAA, A→aBB | a, B→bBB | A, C→a.

Asked in: CD-501 | December 2024 | 4(b)

Answer

Use a nondeterministic PDA accepting by empty stack. Its single state p begins with S on the stack; the stack top is written on the left. For each grammar production X→α add δ(p,ε,X) containing (p,α). For each terminal t add δ(p,t,t)={(p,ε)}. The PDA guesses a leftmost derivation and consumes matching terminals.

The complete production-expansion transitions are listed below. C is unreachable from S, but its rule is retained to faithfully represent the supplied grammar.

Input Stack top Replacement
ε S aABB or aAA
ε A aBB or a
ε B bBB or A
ε C a
a a ε
b b ε

Example: S⇒aAA⇒aaA⇒aaa. The corresponding configurations (remaining input, stack) are (aaa,S)→(aaa,aAA)→(aa,AA)→(aa,aA)→(a,A)→(a,a)→(ε,ε). Thus aaa is accepted.

Every successful PDA computation corresponds to a grammar derivation because only production rules expand variables and only matching terminal symbols are consumed. Conversely, a leftmost derivation of any generated word can be simulated by choosing the same expansions. Hence the PDA and grammar recognize the same language.

CFG to PDA: December 2024
CFG to PDA: December 2024

← RGPV CD-501 Theory of Computation December 2024 Solved Question Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion