Homework 5 Solutions
- Construct a context-free grammar AND an nPDA for the following language:
L = {apbqcr | p ≥ q and p ≥ 1 and q ≥ 1 and r ≥ 1 }
S -> XC X -> aXb X -> aX X -> ab C -> Cc C -> c
- Construct an equivalent nPDA for the following CFG:
S -> aAA A -> aS A -> bS A -> a
Write a leftmost derivation for w = aaabaaaaa. Also, show the nPDA stack after each transition in the nPDA that accepts w. - Construct dPDAs for the following languages:
- L = { an bm | n ≥ 0 and n ≠ m }
- L = { w1cw2 | w1 ∈ {a,b}* and w2 ∈ {a,b}* and w1 ≠ w2R }
- L = { an bm | n ≥ 0 and n ≠ m }
- Consider the following CFG for Palindromes:
S -> aSa S -> bSb S -> a S -> b S -> ε
Show the parse tree for w = ababbaba, identify repeating non-terminals in a path from root to leaf, and separate w into 5 parts u, v, x, y, and z as the Pumping Lemma suggests.