Professional Documents
Culture Documents
Exam
Moed A 2022: Solutions
1
We claim that hM, wi ∈ HALT if and only if hM1 , M2 i ∈ N EQ.
Assume that hM, wi ∈ HALT . This means that M does not halt
on w. Since M1 runs M on w, it means that M1 does not halt on
any input, and so L(M1 ) = ∅. Since M2 always accepts, we have
L(M2 ) = Σ∗ . Thus, L(M1 ) 6= L(M2 ) and so hM1 , M2 i ∈ N EQ.
Assume that hM, wi ∈ / HALT . This means that M halts on w. Since
M1 runs M on w and then accepts, it means that L(M1 ) = Σ∗ . Since
M2 always accepts, we have L(M2 ) = Σ∗ . Thus, L(M1 ) = L(M2 )
and so hM1 , M2 i ∈
/ N EQ.
Therefore, we have a reduction from HALT to N EQ. Since HALT is
not recognizable, by the reduction theorem N EQ is not recognizable.
3. For natural numbers a, b ∈ N, let
2
Solution: We first show that Half − V C ∈ N P by describing a
polynomial verifier V .
The input for V is a graph G and a witness S ⊆ V (G). V verifies
that |S| = |V (G)|/2 and that S is a vertex cover for G. Since this
can be done in polynomial time, V is indeed a polynomial verifier for
Half − V C, and therefore Half − V C ∈ N P .
We now show that Half − V C is N P -hard. We describe a reduction
from V ERT EX − COV ER to Half − V C. Given an input hG, ki
for V ERT EX − COV ER, we define a graph G0 as follows:
Let n = |V (G)|.
• If k = n/2, set G0 = G.
• If k > n/2, we construct G0 by adding 2k − n isolated vertices to
G.
• If k < n/2, we construct G0 by adding n − 2k + 2 new vertices,
every pair of which is connected by an edge.
We must show that G has a vertex cover of size k if and only if G0
has a vertex cover containing half of its vertices.
Assume that G has a vertex cover S of size k.
• If k = n/2, then S is a vertex cover of G0 containing half of its
vertices.
• If k > n/2, then since |V (G0 )| = 2k, we have again that S is a
vertex cover of G0 containing all of its vertices.
• If k < n/2, then |V (G0 )| = n + m = 2n − 2k + 2. By choosing S 0
to be the union of S and all but one of the new vertices, we get
a vertex cover of size k + m − 1 = n − k + 1 for G0 , as required.
Assume now that G0 has a vertex cover S 0 containing half of its
vertices.
• If k = n/2, then S 0 is a vertex cover of G containing half of its
vertices.
• If k > n/2, then since |V (G0 )| = 2k, we have that S 0 is a vertex
cover of G0 containing k vertices. Therefore, S 0 ∩V (G) is a vertex
cover of G containing at most k vertices. By adding k − |S 0 ∩ G|
arbitrary vertices to S 0 ∩ G, we get a vertex cover S for G of size
k.
• If k < n/2, then |V (G0 )| = 2n − 2k + 2. Since S 0 contains half of
the vertices of G0 , we have that |S 0 | = n − k + 1. Since the new
vertices that we added to G are all connect, S 0 must contain at
least m − 1 of them, so |S 0 ∩ V (G)| ≤ (n − k + 1) − (m − 1) = k.
Once again, if S 0 ∩ V (G) < k, we can construct a vertex cover of
size k for G by adding k − |S 0 ∩ G| arbitrary vertices to S 0 ∩ G.
5. (a) Define a c-approximation algorithm.
3
Solution: A c-approximation algorithm for a problem P is an al-
gorithm A that, given an input x ∈ Σ∗ for P , outputs a solution s
for P such that the ratio between the value of s and the value of an
optimal solution is at most c.
(b) In the parallel-scheduling problem, me must divide n tasks with
completion times t1 , ..., tn to two identical processors, so that the
total time it takes to complete the tasks is minimized. Suggest a 2-
approximation algorithm for the problem, and prove that it is indeed
a 2-approximation.
Solution: The best that an optimal solution can do is to parti-
tion the tasks so that both processors finish at exactly
Pn the same
time. In this case, the total completion time is ( i=1 ti ) /2. The
trivial algorithm that gives the first processor
Pn all of the tasks is a 2-
approximation, since the runtime is i=1 ti , which is at most twice
as much as the time used by an optimal algorithm.