Sei sulla pagina 1di 5

CMPT 705 Assignment 5 solutions

David Wong-Aitken <drw2@sfu.ca>

October 28, 2019

Abstract
This is the solution of the assignment 5, in CMPT 705 Analysis and
design course (Fall 2019), Prof. Qianping Gu with Ehsan Hoseinzade
and Young Shin Oh as TA.

1 Solutions to problem 1 (Chapter 8 problem 2)


The problem is NP since, given a array A and a integer 0 < k ≤ n we can
check in a polinomial time that at most exist one row i in the subset with
A[i, j] > 0.
Now, we need to find a known NP-Complete Y problem that we can
reduce it to an instance of diverse subset problem. If we can do it, then
we can say that Y is polinomial time reductible to diverse subset problem,
that is Y ≤p DiverseSubset. Because Y is NP-Complete, we could say that
Diverse Subset is also NP-Complete. The main work here is find a suitable
Y problem that is NP-Complete and try to get the form to Diverse Subset,
in order to use diverse subset as a black box to solve it.
If we read carefully, we can observe several similitudes between the prob-
lem described here and the independent set problem, because both try to
minimize the number required: in the case of diverse subset, they try to
minimize rows and in the case of independent set, they try to minimize
independent vertex. Let’s construct a solution this way: Create a graph
G(V, E) where every vertex va[i] is a row (we have n rows, then n vertex
in G). A colum A[j] is a collection of cells {A[1, m], . . . , A[j, m]}, where
every cell A[i, j] ≥ 0 (that means it has a value of cero or something greater
than zero). Because our interest is check at most one row i in this subset
is greater than zero, then we can create edges that represent columns in A.
We proceed creating edges between vertex for each row in the same column
where its value is greater than zero. For example, if we got in A[1, 1] = 1

1
and A[2, 1] = 2, then we draw an edge in the vertex va[1] and va[2] ; that
edge means that in our independent set, we just want to select one of those
vertex in order to guarantee that just one row (in our case, row A[1] or A[2])
is selected. Finally, in order to solve the problem, we just need to check if
there is an independent set in G with at least k vertex. If we can solve the
independent set problem, we can solve the diverse subset problem.
Hence we can say that IndependentSet ≤p DiverseSubSet and it com-
pletes our proof that Diverse subset is NP-Complete.

2 Solutions to problem 2 (Chapter 8 problem 4)


2.1 Part a: The general resource reservation problem as
above
In order to check if this problem is NP-Complete, we need to determine
whether is NP. This problem is clearly a NP problem because, we can check
in polynomial time that no resource is requested by more than one processor.
In order to check this problem is NP-complete, we need to find a NP-
Complete problem Y and demonstrate that Y ≤p ResourceAllocation. We
can check that this problem is very similar to Independent Set, where every
vertex is a processor p1 , . . . , pk and every edge is a resource requeriment. If
we have a requirement that is requested by two or more processor, we draw
an edge between them. That edge will guarantee that just one of those
processor allocates the resource, denying the other ones. That configuration
makes IndependentSet ≤p ResourceAllocation and completes the proof that
it is NP-Complete.

2.2 Part b: The special case of the problem with k = 2


If the problem is k = 2, then we can just test the combination of requested
resources (r1 , r2 ) in order to check if there is two disjoint subsects r1 and r2
that make room for two processors. The answer if k = 2 could be allocated
or not can be answered in polinomial time.

2.3 Part c: The special case that there are two types of
resources
If we have two types of resources R and J and at most one resource of
each type is required per process, then there is no competence for resources,
because they are disjoint sets. Therefore, the number of k process that can

2
be allocated it will be limited by the number of R and J and the solution
is just check if there is almost k resources of each, which can be done in
polinomial time.

2.4 Part d: The special case that each resource is requested


by at most two processors
If the resource is requested at most two processors, we can check in poli-
nomial time if those requests collides between them. This demands just a
polinomial time with respect of the size of the resources m.

3 Solutions to problem 3 (Chapter 8 problem 6)


In order to probe this problem is NP-Complete, we need to tacke first
whether this problem is NP. It is NP because for a given values of x1 , x2 , etc
we can check in polinomial time if the given values satisfies all the clauses.
Therefore, we need to check if this NP program is NP complete. How
can we do that? Reviewing if exist an algorithm Y that is NP-Complete
and we can give it the shape of our program, in order to make it polinomial
time reductible. We can do it using independence set problem, because it is
required to minimize the number of variables that are set to 1. We create
each clause as a vertex and each variable used in each clause as a edge, that
connect two vertex. For example, if we have the clause (x1 , x2 ) and (x1 , x3 ),
we can create each clause as a vertex of a graph, and an edge called x1
connecting them. Therefore, if we apply independent set, we need just to
choose one of those vertex and not both because they are not independent.
We generalize this idea with every clause and variable that we have. Let’s
suppose the variable x1 is true, then every clause that has x1 is also true
(because the way the monotone satisfisbility is constructed), also we know
that Ci ∧ 1 = Ci , because that we can ignore the other clauses/vertex as
independence set do, therefore giving the same result. The final goal is just
to check if exist k vertex that are minimum independent set and make the
problem satisfactory, which is when the problem can be solved with final
value 1.
Hence, we can say IndependentSet ≤p MonotoneSatisfiability and the
given problem is NP-Complete.

3
4 Solutions to problem 4 (Chapter 8 problem 21)
The Fully Compatible Configuration (FCC) is a problem that arrises natu-
rally when we have several set of options and an another subset of options
that are incompatible among them. This problem is NP because it is polino-
mial time verificable that for each given configuration, we can check if exist
any element that are incompatible or not among them.
If we want to check if this problem is NP-Complete, we need to check a Y
problem that is NP-Complete and can solve the FCC problem. If we check
the FCC problem, we can see that is a problem of deciding whether exist a
set of elements that are compatible among them. The 3-SAT problem is a
canonical way to decide this question.
Concretely, suppose we are given an instance of 3-SAT consisting of
clauses C1 , . . . , Ck over variables x1 , x2 , . . . , xn . We construct an instance
of FCC as follows. For each variable xi we correspond it with elements of
Ai , in order to form a clause with three elements. For each element in the
incompatible list P , we add it also in a clause, but in its negated form.
Therefore, if we have an element xi and xj that is in Ai and Aj respectively,
but also appears in P as a incompatible items, then the clause (xi ∨ xj ) will
not let to satisfy the arrangement to 1, but if we don’t have that restriction,
then the arragement in CNF form will satisfy to 1, meaning that the FCC
is satisfiable. The solution of the FCC exist if and only if exist a way to
satisfy to 1 the arrangement of variables of 3-SAT problem.
Therefore, we can see that 3-SAT ≤p FCC, that means FCC problem is
NP-Complete.

5 Solutions to problem 5 (Chapter 9 problem 3)


In order to win in the geography game in polynomial time we need to tackle
the problem with tools we already known. A good tool to apply dynamic
programming, because the winner is defined by best move over this this turn
or winning the last n − 1 turns. We create a graph G(V, E) where we put
every turn from bob and alice in topological order (that means, from left to
right) where every vertex is a turn and every edge is the next turn played.
We make A[j] = 1 when the person who makes the move in the turn j can
force a winning. We put A[j] = 0 if that person can’t force a winning.
It is easily seen that the last vertex of our graph is A[n] = 0, because
that person can’t force a next movement, therefore he or she failed. From
this point, we can use Dynamic programming to compute the values for

4
every A[i] in backward order (this means, from the point where there is no
way to force a winning to the start of the game). A given player can win
the game if exist a way for the player t to play the A[i] turn where it has
an edge to other turn and that turn (played by player s) has A[n] = 0 (that
means there is no other possible turn, lossing the game).
This algorithm clearly has polinomial time solution, because every node
n dependes of computing the value of A[n−1] and so on, recursivelly, solving
the game depending on which turn it starts.

Potrebbero piacerti anche