![]() |
![]() |
|
hint: Your parse tree for (b) can refer to the parse tree for (a) if you like.
hint for k: If you have two existing CFGs, it's easy to take their union: add a non-terminal that has one rule "generate anything from the first CFG", and one rule "generate anything from the second CFG".
hint for m:
- The # is just another character (which is handy here to demark the two parts of the string).
- Recall the book's grammar for generating palindromes (that is, a string concatenated to its reverse).
x is a substring of yis the same asy can be expressed as uxw, where u and w are any string. Modifying the book's grammar for palindromes so that its center is not just#, but# followed by any string. That'll get two of the threephasesto the right of the#.
hint: How many states do you need, to keep track of the parity of #a's? Hint: 2. Likewise for the #b's. To keep track of both simultaneously means 2x2 states.(Make sure your machine accepts aababba.)
That is: Specify what the grammar-alphabet V is, what the set of rules R is, and what the start-nonterminal S is.
notation: Recall that if you want to build a set by looping over (say) all \(k\in K\) and union'ing the result, you can use the notation \[ \bigcup_{k\in K} \ldots .\]
Note: These are the same languages as you wrote CFGs for in 11.11.6 — they just re-numbered that part k as part i, here.Give your answers as drawings.
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |