University of Illinois at UrbanaChampaign
Department of Computer Science
Midterm 2
CS 373: Theory of Computation
Fall 2009
Name:
Netid:
•
Print your name and netid,
neatly
in the space provided above; print your name at the upper
right corner of
every
page. Please print legibly.
•
This is a
closed book
exam. No notes, books, dictionaries, calculators, or laptops are permitted.
•
You are free to cite and use any theorems from class or homeworks without having to prove
them again.
•
Write your answers in the space provided for the corresponding problem. Let us know if you
need more paper.
•
Suggestions: Read through the entire exam first before starting work. Do not spend too much
time on any single problem. If you get stuck, move on to something else and come back later.
•
If you run short on time, remember that partial credit will be given.
•
If any question is unclear, ask us for clarification.
Question
Points
Score
Problem 1
20
Problem 2
15
Problem 3
10
Problem 4
15
Problem 5
20
Problem 6
20
Total
100
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
CS 373 Midterm 1 – Fall 2009
2
Name:
1. Short Problems (20 points)
Give answers to each of the following questions, including a short justification. For each, you
will get two points for the correct answer and two points for the correct justification.
(a) Consider a grammar
G
= (
V,
Σ
, R, S
) in which Σ =
{
0
,
1
}
and the only rules are
S
→
A
,
A
→
AB
, and
B
→
A
. What is
L
(
G
)? (4 points)
Sol:
All the rules just substitute variables with variables. Therefore, there is no way to
derive a string in
{
0
,
1
}
*
from
S
. So
L
(
G
) =
∅
.
(b) Is
{
a
n
b
m
c
k
d
n
∈
Σ
*

n, m, k
≥
0
}
a contextfree language? (4 points)
Sol:
Yes, it is the language of this grammar
S
→
aSd

B
B
→
bB

Bc

ε
(c) Let
A
and
B
be any two contextfree languages. Must
A
\
B
be a contextfree language
(here,
\
denotes set difference)? (4 points)
Sol:
Note that for any set
A
, we have
A
= Σ
*

A
and Σ
*
is a CFL. Therefore if the
claim is true, then CFLs would be closed under complementation. So the answer is No.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Viswanathan,M
 Computer Science, Formal language, Contextfree grammar, contextfree language

Click to edit the document details