CS381
Final Exam
Friday, Dec. 12, 2003
Fall 2003
Phillips 101
9:0011:30 am
This is a 2
1
2
hour in class closed book exam.
All questions are straightforward and you
should have no trouble doing them.
Please show all work and write legibly.
Thank you.
1.
Is it decidable for regular sets
1
R
and
2
R
whether
1
2
R
R
⊆
?
Justify your answer.
Answer
:
1
2
1
2
iff
R
R
R
R
⊆
=
I
Φ
.
But
1
2
R
R
I
is a regular set and emptiness for regular
sets is decidable.
2.
Write a contextfree grammar for the compliment of
{
}

(
)*
ww w
a
b
∈
+
.
Answer
:















S
AB BA O
A
aAa aAb bAa bAb a
B
aBa aBb bBa bBb b
O
aaO abO baO bbO a b
→
→
→
→
3. Let
be a contextfree language.
In each string interchange the order of a
and b in each occurrence of ab.
Is the resulting language context free?
Give a proof of
your answer.
(
*
L
a
b
⊆
+
)
Examples
aabb
abab
ababab
bababa
bababa
bbabaa
→
→
→
Answer
:
Define
,
, and R as follows
1
h
2
h
1
2
1
2
1
2
( )
( )
( )
( )
( )
( )
h a
a
h
a
a
h b
b
h
b
b
h c
ab
h
c
ba
=
=
=
=
=
=
(
)
(
)
(
)
*
*
R
a
a
b
c
a
b
c
a
b
c
=
−
+
+
+
+
+
+
*
b
)
R
R
Then the desired set is
.
The class of cfl’s is closed under
homomorphisms. inverse homomorphisms, and intersection with a regular set.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '05
 HOPCROFT
 Formal language, Turing Machines, R1 R2, CFL, 2 1 hour

Click to edit the document details