Assignment 6
Meow
Problem 1 — What a Reduction Means
Suppose there is a polynomial-time reduction from Problem 1 to Problem 2. In one or two sentences, explain whether each statement below is true or false.
- If Problem 1 is NP-complete, then Problem 2 must also be NP-complete.
- If Problem 1 is NP-complete, then Problem 2 must be NP-hard.
- If Problem 1 is NP-complete, then Problem 2 may also be NP-complete.
- If Problem 2 is NP-hard, then Problem 1 must also be NP-hard.
Problem 2 — Two Ways
Prove that deciding whether a \(\text{3-CNF}\) formula has at least two distinct satisfying assignments is NP-complete.
You may first prove that the problem is in NP, and then show a reduction from \(\text{3-SAT}\).
Problem 3 — Subset Sum
SUBSET SUM asks whether a given multiset of positive integers contains a subset whose sum is exactly the target value \(T\).
- (a) Show how the variables and clauses of a 3-SAT instance can be encoded as selected digit positions of integers in base \(B\), so that choosing an integer corresponds to assigning
Trueto the associated literal. - (b) Briefly prove that a subset summing to \(T\) exists if and only if the original formula is satisfiable.
- (c) State precisely what this reduction proves about the complexity of SUBSET SUM.
Problem 4 — Vertex Cover
In VERTEX COVER, a graph \(G=\langle V,E\rangle\) and an integer \(k\) are given. The question is whether there is a vertex set \(S\) of size at most \(k\) such that every edge \((u,v)\in E\) has at least one endpoint in \(S\). Prove that VERTEX COVER is NP-complete by reducing 3-SAT to it.
Solution - Pouria Zarei
Problem 5 — Rectangle Tiling
Consider RECTANGLE TILING: decide whether a rectangular region \(R\) can be tiled using rectangles from a set \(T\), with each tile used at most once. Prove that RECTANGLE TILING is NP-complete when the heights and widths are encoded in binary.
Hint: you may use the NP-completeness of PARTITION or SUBSET SUM.
Solution - Kasra Montazeri
Problem 6 — Hitting Set
Sets \(\{S_1,S_2,\dots,S_n\}\) and an integer \(k\) are given. Decide whether some subset of their union with at most \(k\) elements intersects every \(S_i\). Prove that this decision version of HITTING SET is NP-complete.
Solution - Mohammad Amin Heydari
Problem 7 — Edge Cover
In EDGE COVER, a graph \(G=\langle V,E\rangle\) is given, and we seek a smallest edge set \(S\) such that every vertex \(v\in V\) is incident to an edge in \(S\). Prove that EDGE COVER is in P. Explicitly handle isolated vertices: if one exists, no edge cover exists; otherwise derive a minimum edge cover from a maximum matching.
Problem 8 — Complement Games
Prove that if \(\text{coNP}\ne\text{NP}\), then \(P\ne NP\).
Problem 9 — A Careless Reduction
A Boolean formula is in DNF if it is a disjunction of conjunction terms. An example appears below.
DNF-SAT asks whether a DNF formula is satisfiable: can its variables be assigned True and False so that the formula evaluates to True?
- (a) Show that DNF-SAT can be solved in polynomial time.
- (b) Using distributivity, show that every CNF formula whose clauses contain at most three literals can be written in DNF. For example:
- (c) To solve 3-SAT, we could first use part (b) to convert the CNF formula to DNF and then apply the algorithm from part (a). This seems to solve the NP-complete 3-SAT problem in polynomial time and prove \(P=NP\). What is wrong with this argument?
Solution - Ghazaleh Karimi
Problem 10 — The Shipping Company's Loss
A shipping company must transport \(n\) packages of weights \(a_1,a_2,\dots,a_n\) kilograms between two cities using vehicles of capacity \(B\) kilograms. Prove that the following decision problem is NP-complete: given an integer \(k\), can all packages be transported using at most \(k\) vehicles?
Solution - Amirhossein Esfandiari
Problem 11 — A Colorful Graph
We want to color the vertices of a graph red, blue, and yellow so that adjacent vertices receive different colors. Prove that if 3-CNF-SAT can be solved in polynomial time, then this graph-coloring problem can also be solved in polynomial time.
Solution - Hasna Shah Heydari
Problem 12 — Maximum to Minimum
Let \(G\) be an undirected graph. Consider the following problems:
- SPATH: Does \(G\) contain a simple path from vertex \(a\) to vertex \(b\) of length at most \(k\)?
-
LPATH: Does \(G\) contain a simple path from vertex \(a\) to vertex \(b\) of length at least \(k\)?
-
(a) Show that SPATH has a polynomial-time algorithm.
- (b) Show that LPATH is NP-complete.
Problem 13 — Two to Three
Define \(CNF_k\) as the following decision problem: is a CNF formula in which every variable occurs at most \(k\) times satisfiable? Answer the following questions:
- (a) Show that \(CNF_2\) can be solved in polynomial time.
- (b) Show that \(CNF_3\) is NP-complete.
Problem 14 — Maximum Cut
A cut in an undirected graph partitions its vertices into two disjoint sets \(S\) and \(T\). Its size is the number of edges with one endpoint in \(S\) and the other in \(T\).
MAX-CUT is the following decision problem: given a graph \(G\) and integer \(k\), does \(G\) have a cut of size at least \(k\)?
Using these definitions, prove that MAX-CUT is NP-complete.
Problem 15 — Troublesome Cliques
In graph theory, a clique is a set of vertices every two distinct members of which are joined by an edge.
- (a) Prove that CLIQUE—the problem of deciding whether a graph contains a clique of a specified size—is NP-complete.
- (b) Define HALF-CLIQUE as follows: does an undirected graph \(G\) with \(m\) vertices contain a clique of at least \(\frac{m}{2}\) vertices? Prove that HALF-CLIQUE is NP-complete.
Problem 16 — Factoring in Paradise
Show that if \(P=NP\), then integers can be factored in polynomial time.
Problem 17 — Duality
Consider the following linear program:
subject to
- (a) Write the dual of this program.
- (b) Find a feasible solution to the primal with objective value \(16\).
- (c) Find a feasible solution to the dual with objective value \(16\), and conclude that the solution from part (b) is optimal.
Problem 18 — The Greedy Factory
A workshop manufactures products \(A\) and \(B\). Each unit of \(A\) requires two units of raw material and one hour of labor, yielding profit \(5\). Each unit of \(B\) requires one unit of raw material and three hours of labor, yielding profit \(6\). The workshop has \(100\) units of raw material and \(90\) labor hours.
Write a linear program that models the workshop's maximum profit, and find an optimal solution.
Problem 19 — Shortest Path
The following directed graph is given:
Using variables \(d_v\), complete the following linear program for finding the shortest-path distance from \(s\) to \(t\):
subject to the following constraint for every edge \((u,v)\):
Then set \(d_s=0\), find the optimal value of \(d_t\), and identify its corresponding path.
Solution - Narges Kari
Problem 20 — Maximum Flow
Consider the following network:
Each edge's capacity is written beside it.
- (a) Write a linear program for the maximum \(s\)-\(t\) flow.
- (b) Give a feasible flow of value \(5\).
- (c) Use a simple cut to show that the maximum-flow value is at most \(5\).
Solution - Seyed Mohammad Mahdi Hosseini
Problem 21 — The Dual of Maximum Flow
Let \(P\) be the set of all \(s\)-\(t\) paths in a directed network. For every path \(p\), variable \(x_p\) denotes the amount of flow sent along \(p\). Consider the following linear program:
subject to
- (a) Write the dual of this linear program.
- (b) Show that every \(s\)-\(t\) cut yields a feasible dual solution.
- (c) Show that every feasible dual solution can be used to construct a cut whose capacity is at most the value of that solution.
Problem 22 — Assignment Cost
There are three workers and three jobs. The cost of assigning worker \(i\) to job \(j\) is given by the following matrix:
Write a linear program that minimizes the assignment cost, and find an optimal solution.
Solution - Sajjad Aghili
Problem 23 — Chebyshev Center
The following convex polygon in the plane is given:
Write a linear program that finds the largest circle contained entirely within this polygon, and determine its optimal radius.
Problem 24 — Standard Form
Convert the linear program below to the following standard form:
subject to
Solution - Ali Nematdoust
Problem 25 — Slack Form
Convert the following linear program to slack form and give its initial basic solution:
subject to
Solution - Mehdi Nemati
Problem 26 — Unboundedness
Show that the following linear program is unbounded:
subject to
Problem 27 — Infeasibility
Show that the following linear program is infeasible:
subject to
Problem 28 — Duality Again
For a bipartite graph \(G=(L\cup R,E)\), write the linear programming relaxation for minimum vertex cover. Then derive its dual and explain why the dual is precisely the matching LP.
Solution - Ali Moghaddasi
Problem 29 — Flashback
A collection of time intervals \((s_i,f_i)\) is given.
Problem 1: select the maximum number of mutually compatible intervals, meaning no two selected intervals overlap.
Problem 2: select the minimum number of points such that every interval contains at least one selected point.
Show that the optimal values of these two problems are equal.
Problem 30 — World Cup
The World Cup match schedule is fixed, but the venues have not yet been assigned. There are \(n\) matches, each held during a specified time interval; the intervals need not have equal lengths. Two matches whose times overlap cannot use the same stadium. If one ends at 9 p.m. exactly when another begins, however, they may use the same stadium. As Infantino, compute the minimum number of stadiums needed to host every match. Give an \(\mathcal{O}(n\log n)\) algorithm that computes this number.
Problem 31 — Complicated Moving
Suppose we have \(n\) two-dimensional boxes that must be moved.
Box \(i\) has dimensions \(a_i\times b_i\). The moving company charges per item, so to reduce the cost we want to nest some boxes inside others. To prevent damage, boxes may only be nested parallel to the coordinate axes, and each box may directly contain at most one other box. Thus, the condition for placing box \(i\) inside box \(j\) is:
Give an \(O(n\log n)\) algorithm that computes the minimum number of items we must hand over to the moving company.
Hints
Review Problem 1: Nested Frames from Assignment 1 and Problem 22: Rectangles from Assignment 2.
Solution - Rozhin Taghizadegan
Problem 32 — Linear Matching
Consider the following bipartite graph:
Write a linear program for finding a maximum matching in this graph, and determine its optimal value.
Solution - Fatima Teymarchi
Problem 33 — Removing Ambiguity
In a nonstandard linear program, some variables may be unrestricted. Standard form, however, requires every variable to be nonnegative. Show how to handle unrestricted variables when converting a nonstandard LP to standard form.
Problem 34 — Playing with Norms
Formulate each problem below as a linear program. Explain the relationship between each problem's optimum and that of the equivalent LP.
- (a) (\(\ell_\infty\)-norm approximation)
- (b) (\(\ell_1\)-norm approximation)
- (c)
- (d)
- (e)
In every problem, \(A\in\mathbb{R}^{m\times n}\) and \(b\in\mathbb{R}^m\) are given.
Problem 35 — Distributing Loads
Loads of masses \(M_1,\dots,M_k\) are located at points \(P_1,\dots,P_k\). Warehouses are located at points \(Q_1,\dots,Q_n\), and warehouse \(i\) has capacity \(C_i\). The goal is to transport the loads to the warehouses while minimizing the total work. Define the energy required to move a load as its mass multiplied by the distance it travels.
- (a) State an obvious necessary condition for transporting all loads.
- (b) Suppose the loads are divisible liquids, so portions may be sent to different warehouses. Model the problem as a linear program.
Solution - Niki Rashidian
Problem 36 — Relaxation
In a Boolean linear program, vector \(x\) is constrained to have only zero-one entries:
subject to
Solving such problems is generally difficult, even though the feasible set is finite and contains at most \(2^n\) points.
A general technique called relaxation replaces the constraint \(x_i\in\{0,1\}\) with the linear inequalities \(0\le x_i\le 1\):
subject to
We call this the LP relaxation of the Boolean LP. It is much easier to solve than the original Boolean program.
- (a) Show that the optimum of the LP relaxation is a lower bound on the optimum of the Boolean LP. If the LP relaxation is infeasible, what can be concluded about the Boolean LP?
- (b) Sometimes the LP relaxation has an optimal solution with \(x_i\in\{0,1\}\). What can be concluded in that case? Does the relaxed optimum equal the original optimum?
Problem 37 — A Useful Approximation
VERTEX COVER is NP-complete. Consider the following algorithm for it:
At each step, take the first uncovered edge and add both its endpoints to the selected vertex set. Stop once every edge is covered.
This is an approximation algorithm, but it runs in polynomial time.
Prove that the algorithm is a 2-approximation.
Problem 38 — Set Cover Approximation
SET COVER is defined as follows: Given a universe \(U\) of size \(|U|=n\) and a collection of its subsets \(S_1,S_2,\dots,S_m\), find the minimum number of these subsets whose union is all of \(U\).
Give a \(\ln n\)-approximation algorithm for SET COVER.
Solution - Soroush Davaran
Problem 39 — Approximate Traveling Salesperson
In this version of TSP, the graph is complete and the distances satisfy the triangle inequality.
Give a 2-approximation algorithm and prove its approximation ratio.
Solution - Ilia Yazdani
Problem 40 — Dominating Set
DOMINATING SET is defined as follows: Find a minimum vertex set such that every vertex is either selected or adjacent to a selected vertex.
Give an approximation algorithm with approximation ratio \(O(\log n)\).
Problem 41 — A Vertex-Cover Heuristic
Consider the following heuristic for VERTEX COVER: build a depth-first search tree of the graph and remove all leaves from that tree.
- (a) Show that the remaining vertices necessarily form a vertex cover of the graph.
- (b) Prove that this cover has size at most twice the optimum; that is, the algorithm is a 2-approximation.
Solution - Ilia Forsati
Problem 42 — Fast Matching
Consider the MATCHING problem: - (a) Design an \(O(|E|)\) algorithm that finds a maximal matching in \(G\). - (b) Let \(M\) be a maximum matching in \(G\). Prove that every maximal matching \(M'\) satisfies \(|M'|\ge\frac{|M|}{2}\). In other words, prove that the algorithm from part (a) is a 2-approximation for maximum matching.
(Note that maximum matching is not NP-hard and has an exact polynomial-time algorithm; the goal here is to analyze a fast approximation method.)
Solution - Zahra Ghassabi
Problem 43 — Acyclicity
A directed graph \(G=(V,E)\) is given. Find a largest edge subset \(E'\subseteq E\) such that the subgraph \(G'=(V,E')\) contains no directed cycle.
Hint: Order the vertices arbitrarily and consider forward and backward edges; \((v_i,v_j)\) is forward if \(i<j\). Find an acyclic edge subset containing at least half of all edges.
Problem 44 — The Impatient Governor
A country has \(n\) cities with a road between every pair, so its road network is complete. Assume the distance function is metric (in particular, it satisfies the triangle inequality). Partition the country into \(k\) provinces, each with a capital, while minimizing the maximum distance from a city to its provincial capital. This is the \(k\)-center problem. Let the optimum be \(d\): there is an assignment in which every city is within distance \(d\) of its capital, and no assignment achieves a smaller maximum distance.
Give an algorithm that selects \(k\) capitals so every city is within distance \(2d\) of its capital—a 2-approximation—and prove its correctness.