Review Questions

ANSWER: A B G I C D H E F
ANSWER: A B C G D E I H F
ANSWER:

ANSWER:

ANSWER:
NOTE: Both grammars above generate the same language. The difference come in when the grammars are used in processing. Basically, the deterministic grammar (G2) allows exactly 1 transition for an input symbol for any state, whereas the nondeterministic one (G1) allows 0 or even multiple transitions. So, the processing (i.e., parsing) with deterministic grammar runs much faster.
ANSWER:
The first part with epsilon transitions is easy, so it is omitted. The machine for the second part without epsilon transitions is one of the following.

N = {a,b}
T = {S,A,B}
s = S
P = {S -> AB, S -> BA, A -> Aa, A -> a, B
-> Bb, B -> b}
ANSWER: Context-free grammar
ANSWER:
Regular expression: aa*bb* | bb*aa* (or a+b+ | b+a+ using an extension +)
Set notation: {anbm | n > 0, m > 0} U {bnam | n > 0, m > 0}
S ® ASB | l
A ® aAb | l
B ® bBa | ba
ANSWER:
S Þ ASB Þ aBbSB Þ aaAbbSB Þ aabbSB Þ aabbB Þ aabbba
ANSWER:
S Þ ASB Þ ASbBa Þ ASbbBaa Þ ASbbaa Þ AASBbbaa Þ AASbabbaa Þ AAbabbaa Þ AaAbbbaa Þ AaaAbbbabbaa Þ Aaabbbabbaa Þ aAbaabbbabbaa
Þ abaabbbabbaa
ANSWER: omitted here
ANSWER: {(anbn)i(bmam)i | n >= 0, m > 0 and i >= 0}.
S ®
aaSB | l
B ® bB | b
ANSWER: {a2nbm | n >= 0, m >= n} or {a2nbm+n | n >= 0, m >= 0}
ANSWER:
S ®
AB
A ® aAb | l
B ® bBa |
l
NOTE: This grammar is very similar to the one for Question #4. Differences are:
- Grammar for this question does not allow recursion on S, so the strings do not have repeating substring of "a..ab..b".
- Grammar here allows B to generate a null string/character. So it is actually that n >= 0.