Practice Problems for Exam 2
- Consider the following grammar for prefix expressions:
E -> +EE
E -> * EE
E -> - EE
E -> a
E -> b
Write leftmost and rightmost derivations for w = +*-abab. Draw the parse trees for these derivations.
- Construct an equivalent NFA for the following regular grammar:
S -> bb
S -> aA
S -> bA
A -> ba
A -> bb
A -> bB
B -> aB
B -> bB
B -> bC
C -> a
C -> b
- Write a CFG for the language L = { w | w is a word in {a,b}* and w has twice as many a's as b's }
- Construct a CFG and a dPDA for L = { w | w is a word in {a,b}* and w does not end with "ba" }
- Construct a CFG and a dPDA for
L = {apbqcr | p ≥ r and p ≥ 1 and q ≥ 1 and r ≥ 1 }