# First Midterm Exam, Spring 2011

### Directions:

• Answer the problems on the exam pages.
• There are eight problems for 120 total points. Actual scale was A=112, C=76.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.
• The first six questions are true/false, with five points for the correct boolean answer and up to five for a correct justification of your answer -- a proof, counterexample, quotation from the book or from lecture, etc. -- note that there is no reason not to guess if you don't know.

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 10 points
Q6: 10 points
Q7: 20 points
Q8: 40 points

Total: 120 points
```

Some questions refer to the context-free grammar G which has rules S → aSb, S → bSa, and S → c.

Several questions also refer to the context-free grammar H which has rules S → aS, S → bS, S → Sa, S → Sb, and S → c.

The regular language X is given by the regular expression a*b*.

The regular language Y is given by the regular expression Σ*baΣ*.

• Question 1 (10): True or false with justification: Any context-free language is the language of some PDA that has exactly one final state and that accepts only when its stack is empty.

• Question 2 (10): True or false with justification: The language L(G), where the grammar G is defined above, is the language of some DFA.

• Question 3 (10): True or false with justification: The language L(H), where the grammar H is defined above, is the language of some DFA.

• Question 4 (10): True or false with justification: Neither of the languages L(G) and L(H) is contained in the other.

• Question 5 (10): True or false with justification: The languages X and Y defined above each have at most three classes in their Myhill-Nerode equivalence relations.

• Question 6 (10): True or false with justification: If M1, M2, and M3 are any three PDA's with languages L1, L2, and L3 respectively, then the language [L1(L2 ∪ L3)]* is the language of some PDA. (Here we are using the operations of concatenation and Kleene star on languages, even if those languages are not given by regular expressions.)

• Question 7 (20):

• (a,5) Prove (by any method) that the string abacbab is in L(G).

• (b,5) Describe the language L(G) in English.

• (c,10) Describe (by any method) a PDA whose language is L(G). If you do not use a standard construction, argue that your PDA has exactly this language.

• Question 8 (40): This question uses the regular languages X and Y defined before Question 1. X is the language of the regular expression a*b* and Y is the language of the regular expression Σ*baΣ*, and Σ = {a,b}.

• (a,10) Create two NFA's whose languages are X and Y respectively, using any method. It is possible in each case to have a three-state NFA with no ε-moves.

• (b,10) Using your answer to part (a), construct an NFA whose language is X ∪ Y. You may use the method from the text, the method from lecture, or some other construction, but the latter should be justified.

• (c,10) Construct, by any legitimate method, a DFA whose language is X ∪ Y.

• (d,10) Construct, by any legitimate method, a minimal DFA whose language is X ∪ Y. (A minimal DFA is one such that any other DFA for the same language has at least as many states.) If you believe that your answer to part (c) is minimal, you must justify that claim here.