Exam 2 practice. Each question is graded as 0, 1/3, 2/3, 3/3. 1. Give a DFA, NFA, RE for a regular language. L = {strings of a's and b's that contain at least one a, at least one b, and does not contain either aaa or bbb} Strings not in L: aaa, bbb, ababbba, abbbaabaaab 2. Give a CFG for a CFL language. L = {strings of (, ), [, ], {, } such that it is properly parenthesised} Strings not in L: ([)], (, {], (())) 3. Give a PDA for a CFL language. L = {w w^R | w is a string of a's and b's that starts with a and ends with b} Strings in L: aabbaa Strings not in L: abaaba, bbabbabb, abb, baa, abbabb 4. Prove that a non-CFL language is not CF. L = {w w^R w | w is a string of a's and b's, and w^R is w in reverse} 5. Given the following CFG - PAGE -> CONTENT CONTENT ->

CONTENT

| CONTENT |

# CONTENT

|

## CONTENT

| LIST LIST ->
ITEMS
ITEMS -> ITEM ITEMS | epsilon ITEM ->
• CONTENT
• Note - variables in the grammar are PAGE, CONTENT, LIST, ITEMS, ITEM. epsilon is the empty string. Everything else is a terminal symbol. Give a string that is a member of the language: Give a string that is not a member of the language: Is this language itself closed under star? That is, if a string w is in the language, are ww, www, wwww, etc. also in the language? 6. Write out the transition table for the following PDA: https://www.tutorialspoint.com/automata_theory/images/pda_for_l1.jpg Give a string that is accepted by the PDA: Give a string that is not accepted by the PDA: What is a shortest string accepted by the PDA? If the set of accept states was swapped (so q1, q2, q3 are accept states) - what would the language be? 7. Give the proof idea for the following statement that is true. Statement: if a language L is regular, then it is CF as well. 8. The following statement is not true in general for CF's. Give an example language where the statement is indeed true, and give another example where the statement is not true. Statement: any language that is CF has a PDA that only uses one sybmol for it's stack (so stack alphabet Gamma is just a single letter, say 'a'). 9. Convert the following CFG into Chomsky normal form. S -> a U b T c | epsilon U -> c U | epsilon T -> T a | V V -> b V | b