Title: Final Exam
1Final Exam Computer Science 500 Spring 1999 May
13 This test is closed-book, 120 minutes Please
make sure that you understand what the questions
ask for. Do not hesitate to ask Pete for
clarification (call 505-280-2557 if via
ITV). Please work carefully and be as precise as
reasonably possible. Note this test is graded
out of 150 points although 160 points are
possible including the extra credit question
2Problem 1 State and prove the Pumping
Lemma
15pts
- If L is a regular language, then
- there exists a value n such that
- for all w in L such that w gt n,
- there exists x,y,z such that w xyz where
y gt 0, xy lt n - for all i gt 0, xyiz is in L
3Proof
Given w w1 w2 wk, let s1s2 sk1 be the
consecutive states reached by D on w (where
s1s) If kgtnD, then by the pigeon hole
principle, we know that exists i,j, iltj, in 1
k1 such that si sj Then x w1 w2 wi-1 puts
D in state si and so does xy w1 w2 wi-1
wi wj-1 and so does xyt w1 w2 wi-1
wi wj-1t
4Proof visualization
x w1 w2 wi-1
s1
si
y wi wj-1
z wj wk
sk1
accept
5Proof continued
z wj wk takes D from state si to sk1, an
accept state So xytz w1 w2 wi-1 wi
wj-1t wj wk takes D from the start state to
the same accept state
6Problem 2 Let L 1n2 n is an integer Prove
that L is not regular
10 points
Let n be any constant Choose the string w1n2.
Note w?L and w? n, let x,y,z be any possible
partition of w such that xy?n and ygt0 Note
this results in y being a string of 1s. Let
i2 xyiz 1n2y. (n1)2gtn2 y gt n2 implies
that this is not in L. The contrapositive of the
pumping lemma implies that L is not regular.
7Let L w w is a binary string of Hamming
weight 0 mod 2 OR w 1 mod 2 10points
Problem 3a draw an NFA that accepts L
0
0
1
C
A
1
e
0,1
B
D
0,1
810points Problem 3b convert the NFA of
part 3a to a DFA (hint the NFA of 3a can
be written using 4 states)
1
C,D
A,B
A,B
9Problem 4 Consider the language L M L(M) ?
A where A is a fixed P2-complete language a)
Write a Kleene hierarchy description for L and
state which class therefore contains L
10pts
Let A x ? b, ? c p(x,b,c) L M ? x,
x? L(M) --gt x ? A L M ? x, x ? A OR x ?
L(M) L M ? x,b,n ? c p(x,b,c) OR
M does not accept x within n steps P2
10Problem 4b Is L recognizable? Prove your
answer
10pts
No. Case 1 of Rices theorem applies
11Problem 4c Is L co-recognizable? Prove your
answer
10pts
No. We prove that A ltm L f domain(A) --gt
T.M.s f is computable ? x, x ? A iff f(x) ? L ?
x, f(x) is a T.M. that, on input w, If w x,
accept. Else, reject x ? A implies L(f(i))
x ? A x ? A implies L(f(i)) x ? A
12Problem 5.
Vertex Cover (G,k) graph G (V,E) and there
is a subset of vertices V of size k such
that every edge in E is adjacent to a vertex of
V a) Show that Vertex Cover is NP-hard by
reduction using 3-SAT
15pts
Hint write a boilerplate
133-SAT ltp Vertex Cover
Input Boolean formula F (a or b or not c)
AND ((not a) or b or d) AND C clauses using N
variables
Output graph G G has a vertex cover of size
2C N if and only if F is satisfiable
14Output graph GC triangles and N pairs
a
a
b
d
b
c
15- Each instance vertex of a variable is connected
to one - of the variables pair vertices
- T if the instance is not negated
- and F if the instance is negated
16Showing the construction reduces 3-SAT to vertex
cover
1. If there is a satisfying assignment then
there must be a vertex cover of size 2C N 2.
If there a vertex cover of size 2C N then there
must be a satisfying assignment
(reduction does not necessarily preserve the size
of the witness set)
17Dominating Set (G,k) graph G (V,E) and
there is a subset of vertices V of size k
such that every vertex in V-V is adjacent to
a vertex of V 5b Prove that Dominating Set
is in NP Dominating Set (G,k) ? V G
(V,E), V? V, every v in V-V is adjacent to
some v in V Hence Dominating Set is in S1p
10 points
1810pts
Extra-Credit Problem 5c Prove that Dominating
Set is NP-hard by reduction using Vertex Cover
Hint write a boilerplate (3 points only for
this in this E.C. Problem), use vertex cover,
and think about edge covered by one vertex in
one problem, triangle covered by one vertex in
the other problem
19 Problem 6 10 points a) draw a diagram
showing the known and believed containments of
regular languages, P, NP, NP-complete languages,
PSPACE, S0, S1, and P1 Point out which
containments are not proven
20Problem 7 (True or False or Unknown/not yet
proven) a) ? A, B, if A,B are regular and B ?
C f and A B ? C then C is regular b) Regular
languages are a proper subset of P c) ? A
regular language A such that A1/2 x ? y,
y x and xy? A is not regular d) ? A, B,
if A,B are regular and A B ? C then C is
regular
4 points each
21Problem 7 (True or False or Unknown/not yet
proven) -- continued e) ? A ? B such that A ? S1
and if B ? S1 then A?B ? S1 f) ? A, igt0, if A ?
Si - (Si-1 ? Pi-1), then A is Si-complete g) Let
L M L(M) A where A is a S3-complete
language, then L is co-recognizable
22Problem 7 (True or False or Unknown/not yet
proven) -- continued h) PSPACE ? NP i) If a
researcher discovered an algorithm that solves
almost all subset sum questions correctly then P
NP j) If P NP then chess and other similar
deterministic 2-player games can be played
perfectly by polynomial time (real-world)
computers