CheatSheet3
CheatSheet3
Feasible set S is empty, LP has no solution || S is 1) Construction: For each Boolean variable in 3-SAT we 1
for 2 bins with R = 2 Σ𝑖 𝑠𝑖, this means the sum of elements
unbounded, LP may or may not have a solution || S is create a vertex in G. All vertices corresponding to a given
in both bins are equal and all the elements are in them, so
bounded, LP has atleast one opt solution clause are connected to each other. This is because we
these bins would be the solution to the partition problem.
Standard algorithms for solving LP is simplex algorithm, want to make sure that only one vertex per clause is
(One of them can be S) || Proof from the other direction: If
Ellipsoid alg. chosen in an independent set. This step creates k triangle
there is a solution for partition problem, it means we have
𝑇
Standard form: 𝑚𝑎𝑥(𝑐 𝑥) subject to 𝐴𝑥 ≤ 𝑏, 𝑥 ≥ 0. This is subgraphs. If there are fewer than three literals, we can set
two sets that cover the whole set and sum of elements in
the primal(P). the missing literals to any present literals. Connect a vertex 1
corresponding to a literal x to all vertices in G each of them is R = 2 Σ𝑖 𝑠𝑖. So this would also be a solution
min → max by x with (-1) || 𝑎𝑥 ≥ 𝑏 → − 𝑎𝑥 ≤− 𝑏 ||
𝑎𝑥 = 𝑏 → − 𝑎𝑥 ≤− 𝑏,𝑎𝑥 ≤ 𝑏 || Free var corresponding to its negation ¬x. We do not want to have for bin covering problem.
two complementary vertices in one independent set. Q. MSFTV PROBLEM
𝑥 = 𝑢 − 𝑣, 𝑢, 𝑣 ≥ 0 || 𝑥 ≥ 𝑐 → 𝑧 ≥ 0 and 𝑥 = 𝑧 + 𝑐
𝑇 𝑇 Claim: 3-SAT instance with k clauses is satisfiable iff G has Certificate: Assignment for variables which has poly-length /
Dual(D): 𝑚𝑖𝑛(𝑏 𝑦) subject to 𝐴 𝑦 ≥ 𝑐, 𝑦 ≥ 0 an independent set of size k. size || Certifier: Check for all clauses to be true and at most
Weak Duality: optimum(D) 2) Forward Proof: Assume we have a truth assignment. k variables to be true in the given assignment. This take
is an upper bound to the Since the assignment makes each clause true, then at least O(mn) steps, i.e. Poly-time. Hence this is in NP by
P/D FB FU I 𝑇 𝑇
optimal(P) - 𝑐 𝑥 ≤ 𝑏 𝑥 || If one literal of each clause must be true. For some clauses definition. Construction from Vertex Cover: Starting with an
a standard problem and its we may have a few of such literals; we then arbitrarily pick instance of the VC problem, we formulate an MSFTV
FB Y N N
dual are both feasible, then one. Construct a set S of k vertices in G by choosing the instance by representing each node v in the graph with a
both are feasible bounded. vertex corresponding to the selected literal from each variable x_v and each edge (u, v) with a clause (x_u V x_v).
FU N N Y
|| If one problem has an clause. S is an independent set. (Some have attempted a more complicated way which is to
unbounded solution, then 3) Backward Proof: Suppose G has an independent set S consider the set of edges as a union over cliques (edges
I N Y Y the dual of that problem is of size k. Then S must include exactly one vertex from each are a special case as 2-cliques), and construct a clause for
infeasible || No duality gap clause. Also, S cannot have vertices representing a literal each such clique). Having constructed the clauses,
in LP. and its negation. We set all vertices in S to true. For consider a boolean AND with the same k as the input. This
𝑇 𝑇
Strong Duality: 𝑐 𝑥 = 𝑏 𝑥 if P & D are feasible. vertices not in S, we choose the assignment arbitrarily. expression is monotone and thus a valid MSFTV instance.
Eg) Infeasible Primal: 𝑚𝑎𝑥(2𝑥 + 𝑦) st Thus, the independent set S yields a satisfying truth Then return YES IFF the MSFTV blackbox returns yes. This
assignment. takes polynomially many steps and just 1 call to the
𝑥 − 𝑦 ≥ 4, 𝑥 − 𝑦 ≤ 2 →
Therefore, since this problem is both in NP and NP-Hard, it blackbox, thus a valid reduction. Iff the blackbox returns
Infeasible Dual: 𝑚𝑖𝑛(− 4𝑎 + 2𝑏) st
is an NP-Complete Problem. YES, there’s an assignment with k true vars, such that each
𝑎 − 𝑏 ≤− 2, 𝑎 − 𝑏 ≥ 1
clause must be true. Hence, choosing a vertex to be in the
Weak Duality always holds, strong duality may not hold for
Q.Suppose that we have developed an approximation cover whenever it’s set to 1 in MSFTV, covers the
ILPs.
algorithm that takes as input a graph G=(V,E) and a real corresponding edge by construction and yields a k-sized
TB Q4) (1000 - x - y)1.06 + 0.1x + 0.2y = a (cash in hand after 1st
year) || (a - z)1.06 + 1.1y = b number ρ > 1 and returns a vertex cover whose size is VC. (Analogous argument for Set cover/ Dominating set
Obj: max(1.06b + 1.3x + 1.5z) || x,y,z ≤ 500 || x+y ≤ 1000 || z ≤ a || less than ρ times the size of a minimum vertex cover. constructions). Thus, VC <=p MSFTV. Since VC is
x,z,y ≥ 0. Prove that the running time of this approximation NP-complete, MSFTV is NP-hard. Since it’s also in NP by
algorithm is not polynomial in the size of the input part 1), it is NP-complete.
NP completeness: unless P=NP. Q. Prove (MST-D2) is NP-Hard: Input: Undirected,
P: Set of problems that can be solved in polynomial time by We can use this algorithm to solve the vertex cover connected graph G = (V, E) with edge weights we. We
a deterministic TM || A fundamental complexity class problem exactly: Set ρ to some value slightly above 1,e.g. are also given U which is a subset of vertices of the
EXPTIME is a class of decision problems that can be 1<ρ<1+1/n (where n is the num of nodes in G). Then the graph (U⊂V). Output: Find the spanning tree of
solved by a deterministic Turing machine in O(2p(n)) time, approximation algorithm must find the optimal vertex cover minimum total weight such that all nodes of U have
where p(n) is a polynomial || A decision problem is set, since even if the size of the set is 1 more than the size degree 2 (if such a tree exists).
decidable if it can be solved by a Turing machine which of the optimal set the approximation ratio will be violated. Show that Hamiltonian Path ≤p MST-D2 Given G an
always halts, otherwise it is undecidable. Eg) The halting We can use this algorithm to solve the IS problem exactly: undirected graph – an instance of the Hamiltonian Path
problem - NP Hard || NP: Set of problems that can be IS<=p VC. problem, we will construct G’ an undirected graph with unit
solved in polynomial time by an NDTM OR set of problems Lemma: I is a Maximal Independent Set of G(V,E) if and weights on all edges. Then for every pair of nodes in G (say
for which solution can be verified in polynomial time by only if V∖I is a Minimal v and u), we will call the black box that solves MST-D2 and
deterministic TM. Vertex Cover G(V,E). instance of IS with max IS = k, then p set U=V-{v,u}. There will be O(n^2) calls to the black box. If
If 𝑌≤𝑝𝑋, 𝑋 is at least as hard as 𝑌 or 𝑌 is at most as hard as 𝑋 satisfies: p(n-k)<(n-k)+1=>p<1+1/(n-k), we can select any of these calls returns a tree such that all nodes in the
𝑋 is NP-Hard is ∀𝑌 ϵ 𝑁𝑃 and 𝑌≤𝑝𝑋 1<p<1/n, Then the approximation algorithm must find the tree have degree 2 except for v and u, it means that we
optimal IS, since even if the size of the set is 1 smaller than have found a Hamiltonian Path in G with v and u as its end
𝑋 is NPC if 𝑋 is NP-Hard and 𝑋 ϵ NP
the size of the optimal set the approximation ratio will be points. If none of the calls to the black box manage to
3SAT: A literal is a va or its negation return such a tree, then we can conclude that G has no
violated.
A clause is a disjunction of literals Hamiltonian Paths.
Q. Consider a special case of the Traveling Salesman
Cook-Levin Theorem: CNF SAT is NPC || 2SAT is in P Q. Prove that Min-Cost Fast Path is in NP
Problem called TSP379 where each edge in the graph
Independent Set, Vertex Cover, Hamiltonian Path/Cycle, Certificate: an s-t path with total cost ≤C and total time ≤T
has a weight of either 3, 7, or 9. Prove that TSP379 is
SAT, Coloring. Certifier: Can easily check in polynomial time that a- Set of
NP-Complete. a) Prove that TSP379 is in NP.
3SAT≤𝑝Independent Set,Graph Coloring, ILP, Vertex Cover. Certificate: A TS tour v1, …, vn (2 points) edges given are in fact a path from s-t || b- Total time is ≤T
To show that 𝑋 is NPC: Certifier: Check that all the nodes are visited once. Check and total cost is ≤C || a and b can be easily done in
1) Show that X is in NP that length of the tour is at most k. Both can be done in polynomial time. Min-Cost Fast Path ϵ NP
2) Pick a known NPC problem
poly-time. b) Prove that TSP379 is NP-hard Choose Subset Sum for our reduction
3) Prove 𝑌≤𝑝𝑋 (Construction)
Reduction from HC: Given G, an instance of HC, construct Will show that Subset Sum ≤p Min-Cost Fast Path
4)Prove that an instance of 𝑋 is
G’ with, Same set of nodes as G, Includes all edges in G Background: Decision version of the Subset Sum problem
true, given an instance of 𝑌
with weight 3, Make G’ a fully connected graph by adding asks whether given n items where item i has weight wi, if
5)Prove that an instance of 𝑌 is
true, given an instance of 𝑋 all the edges that are not in G with a weight of 7 or 9. Set k there is a subset of them whose total weight is less than W
Any problem in P is also in NP. = 3n. Claim: G’ will have a TS tour of at most 3n iff G has a and greater than M.
If 𝐴≤𝑝𝐵 and 𝐵 ϵ NP then 𝐴 ϵ NP HC. Proof of reduction: If G has a HC, since they have a Plan: We build a graph G such that it has an s-t path with
weight of 3 in G’ by construction, they form a TS tour of G’ total cost ≤W and total time ≤Σwi – M iff there is a subset of
with weight at most 3n. If G’ has a TS tour of at most 3n, all items whose total weight is between M and W.
3SAT - Variable gadgets, clause gadgets || Independent
the edges in the tour must have a weight 3 (since there are We use gadgets to represent each item. Each gadget will
set/Vertex cover - graphs where vertices are entities and
n edges in that cycle and min possible weight is 3). By offer two paths through the gadget. If the s-t path in G goes
edges represent relations.
construction, these edges must be present in G, hence they through the A node of the gadget we can interpret that as
For G=(V,E), S is an independent set if and only if V-S is a
form a HC of G item being selected as part of the set. If the s-t path goes
vertex cover.
Q. BIN COVERING/Partition PROBLEM through the B node of the gadget we interpret that as the
Max independent set and clique are complements.
Bin Covering is in NP using packing problem to check a item not being selected as part of the set. We string up the
3SAT ≤𝑝 Independent Set:
proposed solution to confirm a YES instance. The reduction gadgets and set time te and costs ce to edges as follows:
NP: Assume we have an independent set S. For each 1
from Partition is as follows. Set k=2 and R = 2 Σ𝑖 𝑠𝑖, where
vertex in S we check every edge incident to it. If there is an
edge that connects two vertices in S, the solution is not an si = xi. Clearly, there is a bin covering that uses two bins if
independent set. Otherwise we accept S as the and only if there is a partition S⊂[n] such that: ∑ 𝑥𝑖 = ∑ 𝑥𝑖
independent set. This takes polynomial time hence this 𝑖ϵ𝑆 𝑖∉𝑆
problem is in NP.
Proof: A and b can be easily done in polynomial time. Steiner FALSE Let X and Y be decision problems in NP, and assume P ≠ NP.
A- If we are given a set of items with total weight between Tree Problem ϵ NP If X ≤P Y and Y ≤P X, then both X and Y are NP-complete.
FALSE If A is a problem in NP and if A can be solved
M and W, we can find a path from S to T with total cost of at Choose vertex cover for our reduction || Will show that
deterministically in polynomial time, then P = NP.
most W and total time of at most Σwi – M by choosing the Vertex Cover ≤p Steiner Tree Problem TRUE Let TWO denote the problem of deciding whether a given
path through each gadget based on whether the item is part We will start with an instance of the vertex cover problem integer is even. Then TWO is polynomial time reducible to 3-SAT.
of the set (Go through the A node) or not (go through the B (Is there an vertex cover of size at most k in G) and will FALSE A vertex that is part of a Minimum Vertex Cover can never be
node). If we go through the A node for object i, the object construct G’ such that G has a vertex cover of size at most part of a Maximum Independent Set
contributes wi to the cost of the path and if we go through k iff G’ has a Steiner Tree of cost at most m+k. Construction FALSE The NP-Hard class of problems does not contain any
decision problems.
the B node, the object contributes wi to the total time for the of G’: G’ will have the same set of nodes and edges in G
TRUE If every edge in a Flow Network is saturated due to flow F,
path. So the total cost for the path will be the total weight of plus a number of new nodes and edges. The nodes in G’ then F must be a max flow.
the objects selected which we know if ≤ W and the total that exist in G will belong to the set S. We now introduce a FALSE If every edge in a Flow Network G is saturated due to flow F,
time of the path is total weight of the objects that are not new set of nodes in G’: We will add one node (re) per edge then G has a unique max flow.
selected which we know is Σwi – M (because we know the e in G’ (adding m nodes in this process). All these nodes FALSE If there exists an algorithm that solves problem X with
total weight of the objects selected is ≥ M) will belong to the set R || We will connect each node to the pseudo-polynomial runtime, then X must be NP-Hard.
TRUE Based on the definition of polynomial time reduction, we can
B- If we are given a path from S to T which has a total cost two ends of the corresponding edge in G’|| We will add one
say that linear programming is polynomial time reducible to max flow
of at most W and a total time of at most Σwi – M, we can more node r0 in G’ and will connect r0 to all the nodes in TRUE Suppose there is a 7-approxmiation algorithm for the general
find a set of objects with total weight between M and W. the set S in G’ || All edges in G’ will have a cost of 1 Traveling Salesman Problem. Then there exists a polynomial time
The S-T path can easily select the objects that belong to Proof of correctness for the reduction step: solution for the 3-SAT problem.
the set. If the path goes through the A node for an object, A- If we have a vertex cover of size k in G, we can produce FALSE We can use the non-scaled version of the Ford-Fulkerson
we place that object in the set, otherwise not. Since the a Steiner tree of cost m+k in G’. This can be done by using algorithm to find max-flow in weakly polynomial time, and use the
scaled version of the algorithm to find max-flow in strongly polynomial
total cost of the path is at most W then the total weight of the following edges in the Steiner Tree || k edges that
time.
the objects selected will be at most W and since the total connect r0 to the node in G’ corresponding to those k FALSE Suppose, T(n) = T(n/2)+logn then T(n) = O(logn).
time for the path is at most Σwi – M, the total weight of the nodes that form a vertex cover of size k in G. || m edges FALSE If X <=p Y, then an α-approximation algorithm for Y will give
objects not selected will be Σwi – M, which means that the that connect each of the re nodes in G’ to the node that us an α-approximation algorithm for X
total weight of objects selected will be at least M. covers in e in G. This will result in a tree of cost m+k that FALSE Let S denote the set of problems reducible to problem X,
Q. Prove SAT is polynomial time reducible to the 3-SAT covers all nodes in the set R. where X is NP-hard. Then every problem in S must be in NP.
UNKNOWN A general 3-SAT problem cannot be solved in
We will turn each clause of size k in the SAT problem into B- If we have a Steiner tree of cost m+k in G’ we can
polynomial time.
one or more clauses of size 3 as follows: In general, we can produce a vertex cover of size k in G. This can be done by TRUE If a general integer programming optimization problem can be
turn any clause of size k>3 into k-2 clauses of size 3 using putting all the nodes in the set S that are part of the Steiner reduced in polynomial time to a linear programming problem, then P
k-3 dummy variables to “chain” the clauses together using tree in the vertex cover set. (m of the edges will be needed = NP.
conjunction. || Proof: We need to show that the clause of to connect re nodes to one of the S nodes. The other k TRUE If a problem is both in NP and NP-hard, then this problem is
size k is satisfiable iff the chain of clauses of size 3 is edges in the tree will be connecting these S nodes (that are NP-complete.
TRUE A matching in a bipartite graph G=(V, E) can be tested in
satisfiable. To show this: part of the tree) to other S nodes on the tree (for example
O(|V|+|E|) time to determine if it is a maximum size matching.
A – if we have a satisfying truth assignment in the clause of through node r0). Since these S nodes have direct TRUE For a graph with all edges having distinct weights there is a
size k, we can find a satisfying truth assignment in the connections to all nodes in the set R, then the nodes unique MST
chain of clauses of size 3, because the satisfying truth corresponding to these S nodes in G will form a vertex TRUE Let ODD denote the problem of deciding if a given integer is
assignment in the clause of size k requires at least one of cover of size k.) odd. Then ODD is polynomial time reducible to Vertex Cover.
the terms in the clause to be true. This will cause one of the Q. Consider an undirected graph G. Which of the FALSE f we find a quadratic time solution to an NP-Complete
problem, then all NP-complete problems can be solved in quadratic
(k-2) clauses of size 3 in the chain to evaluate to 1, we can following statements are true? a) The problem of
time.
then use the k-3 dummy variables to set the remaining determining whether there exists a simple cycle in G is in TRUE Independent Set problem has a polynomial run time on certain
clauses to be true and therefore find a satisfying truth NP. b) The problem of determining whether there exists a types of graphs.
assignment for the chain. simple cycle of length k in G is in NP-complete. c) The TRUE Consider two decision problems Q1, Q2 such that Q1 reduces
B – if we have a satisfying truth assignment in the chain of problem of determining whether there exists a simple cycle in polynomial time to Hamiltonian Cycle and Hamiltonian Cycle
clauses of size 3, it must be that at least one of the Xi that visits all nodes in G is in NP-complete. d) The problem reduces in polynomial time to Q2. Then it is possible for both Q1 and
Q2 to be in NP.
variables is true (because the dummy variables on their of determining whether there exists a simple cycle that
TRUE The problem of determining whether there exists a cycle in an
own can only set k-3 clauses to true). And a satisfying truth visits all nodes in G is in NP-hard. undirected graph is in NP.
assignment in the clause of size k requires only one of the Q. Which of the following statements are known to be FALSE If the edge weights in a connected undirected graph G are
Xi variable to be true. So this will be a satisfying truth true? There are problems in NP that can be solved in NOT all distinct, then there will be more than one minimum spanning
assignment. polynomial time tree in G.
Q. Prove that Set Packing is in NP Q. Given a directed graph G, two distinct nodes S and T FALSE Dijkstra’s algorithm works correctly on graphs with
negative-weight edges, as long as there are no negative-weight
Certificate: a subset of k sets (out of the m sets given) that in G, and a number k, which of the following decision
cycles.
have no elements in common || Certifier: Can easily check problems are NP-complete? Determine whether there UNKNOWN If Integer Linear Programming ≤p A, then A cannot be
in polynomial time that || There are k sets in the certificate || exists a simple path of length at least k from S to T. solved in polynomial time.
The k sets have no elements in common || A and b can be TRUE - FALSE TRUE Suppose that the capacities of the edges of an s-t flow
easily done in polynomial time. Set Packing ϵ NP TRUE If P = NP, then all problems in P are NP-complete. network are integers that are all evenly divisible by 3. (E.g., 3, 6, 9,
Choose independent set for our reduction || Will show that FALSE Assuming that we have found a correct optimal solution to an 12 ..) Then there exists a maximum flow, such that the flow on each
LP problem, if someone claims to have found a different optimal edge is also evenly divisible by 3.
Indep. Set ≤p Set Packing || We will start with an instance
solution, we know that that solution must be incorrect. FALSE Suppose that G is a directed, acyclic graph and has a
of the Indep Set problem (Is there an indep set of size at FALSE Let X and Y be decision problems for which there exist topological ordering with v1.v1 the first node in the ordering and
least k in G) and will construct a set of sets such that there efficient certifiers, and assume P ≠ NP. If X ≤P Y and Y ≤P X, then vn.vn the last node in the ordering. Then there is a path in G from
are k of them that have no elements in common iff we have both X and Y are NP-complete. v1.v1 to vn.vn.
an independent set of size k in G. || Construction of sets: TRUE Minimum Spanning Tree (MST)≤P Hamiltonian Path. For the next four questions consider a flow network G, increase the
For each node i in G we will create a set Si . The elements TRUE The optimization version of the Linear Programming is not in capacity of an edge e by an amount x>0 to obtain Network G’. Let f, f’
NP. denote the value of max flow in G, G’. Then,
of Si will consist of the edges incident on i in G. || Proof of
TRUE If P=NP, then some NP-hard problems can be solved in FALSE f’ - f is either 0 or x.
correctness for reduction step: polynomial time. FALSE If there is a min-cut in G containing e and f’>f, then there’s a
A – If we have an indep set of size k in G, we can use that FALSE Even if P≠NP, there is a polynomial-time algorithm for the 0/1 min-cut in G’ containing e.
to find k sets that have no common elements. The reason is Knapsack problem when all items have the same weight-to-value TRUE If f’ = f, there is no min-cut in G’ containing e
that since the k nodes in G are independent they do not ratio FALSE If f’ = f, there is no min-cut in G containing e.
share any edges, therefore the sets corresponding to these TRUE If P = NP, then every decision problem whose solution can be
verified in polynomial time can itself be solved in polynomial time.
k nodes will not have any elements in common since these
TRUE Integer Max Flow (where flows and capacities are
elements correspond to the edges incident on the k nodes integer-valued) is polynomial-time reducible to Linear Programming.
in G. B – If we have k sets that have no elements in FALSE Maximize Σxi(1 - xi) (1 ≤ i ≤ n) subject to xi + xj < 1 and
common, we can find an indep set of size k in G. The xi∈{0, 1} (1 ≤ i ≤ n, 1 ≤ j ≤ m) where n and m are constants, is an
reason is that since these sets do not have any elements in integer linear program.
common, the corresponding nodes in G will have no edges TRUE Linear Programming is polynomial-time reducible to
Maximum-Flow.
in common or in other words they will be independent, and
TRUE If Hamiltonian Cycle is polynomial time reducible to Interval
will form an indep set of size k. Scheduling, then P = NP.
Q. Prove that the Steiner Tree Problem is in NP F Not every decision problem in P has an efficient certifier.
Certificate: a tree of cost at most C that covers all nodes in TRUE The problem of deciding whether a graph has a vertex cover
R || Certifier: Can easily check in polynomial time that of size k is NP-hard.
a- Tree covers on nodes in R (run BFS on the tree) FALSE If Y ≤P X, and there exists an efficient 2-approximation
algorithm for X, then there must exist an efficient 2-approximation
b- The total cost of the tree is at most C
algorithm for Y.