Example Midterm Exam - University of Connecticut

advertisement
University of Connecticut
Computer Science and Engineering
CSE 3502
Sample Midterm Exam
Example Midterm Exam
NAME: _____________________________________
This is a “closed book/closed notes” test
Make sure to show your work and explain your answers.
No credit will be given for lucky guesses.
0. [1 pt] Do you understand the instructions above?
Yes
No
Question
Max
0
1
1
25
2
25
3
25
4
25
TOTAL:
Sub-total
101
Earned bonus points:
GRAND TOTAL:
1
University of Connecticut
Computer Science and Engineering
1
CSE 3502
Sample Midterm Exam
Finite State Automata, Regular Languages, Push-Down Automata, Context-Free Languages [25 pts]
a) [5 pts] On the basis of what was covered in class, draw the Venn diagram representing the following sets:
1.
2.
3.
4.
5.
REXP: the set of the language given by all regular expressions
DFSA: the set of all languages recognized by deterministic FSAs
NFSA: the set of all languages recognized by non-deterministic FSAs
CFG: the set of all languages generated by context free grammars
PDA: the set of all languages recognized by PDAs
b) [10 pts] For the following sets, show where in your diagram each set belongs (assume the alphabet Σ is {a,b,c}),
and explain why each set is positioned in a certain place of your diagram.
n n+1
(1) the set A = { a b c* | n ≥ 0 }
(2) the set B = a*b*c*
n n+1 n+2
(3) the set C = { a b
c
| 0 < n < 264 }
c) [10 pts] If one or more of the sets from (b) is a context-free language, pick one and give a PDA that recognizes
that language. Otherwise, pick any of the languages and give a NFSA that recognizes it.
2
University of Connecticut
Computer Science and Engineering
2
CSE 3502
Sample Midterm Exam
Closure Properties of Regular Languages and Context-Free Languages [25 pts]
1) [2 pts] Are Regular Languages closed under union? Yes [ ] No [ ]
[3 pts] If “yes”, sketch a proof, if “no” show a counterexample.
2) [2 pts] Are Regular Languages closed under intersection? Yes [ ] No [ ]
[3 pts] If “yes”, sketch a proof, if “no” show a counterexample.
3) [2 pts] Are Regular Languages closed under concatenation? Yes [ ] No [ ]
[3 pts] If “yes”, sketch a proof, if “no” show a counterexample.
4) [2 pts] Are Context-Free Languages closed under union? Yes [ ] No [ ]
[3 pts] If “yes”, sketch a proof, if “no” show a counterexample.
5) [2 pts] Are Context Free Languages closed under concatenation? Yes [ ] No [ ]
[3 pts] If “yes”, sketch a proof, if “no” show a counterexample.
3
University of Connecticut
Computer Science and Engineering
3
CSE 3502
Sample Midterm Exam
Automata and Languages They Recognize [25 pts]
(a) [10 pts] What is the language recognized by the following NFSA?
Give a regular expression and an informal description
ε
1
a, b, c
2
a
c
3
b
(b) [10 pts] Construct a deterministic finite state automaton with exactly 8 (eight) states that recognizes
the same language or explain why this is impossible.
(c) [5 pts] Give a Context-Free Grammar that generates the same language.
4
University of Connecticut
Computer Science and Engineering
4
CSE 3502
Sample Midterm Exam
Finite State Automata and Regular Languages [25 pts]
1. [10 pts] Show that, if D is a DFSA such that A = L(D), then swapping the accept and non-accept states
of D produces a DFSA that recognizes Σ* − A, the complement of A.
2. [10 pts] Construct DFSAs that recognize languages A and B over Σ= {a, b} below.
i. B = a*b*.
ii. C = Σ* − a*b*.
3. [5 pts] Show by giving an example that, if M is a NFSA such that A = L(M), then swapping the accept
and non-accept states of M does not necessarily produce a NFSA that recognizes Σ* − A.
5
Download