Time Complexity
[54/96%]Answer each part TRUE or FALSE.
.
.
ᴬ .
ᴬ .
.
.
Answer each part TRUE or FALSE.
.
.
ᴬ .
ᴬ .
.
.
Which of the following pairs of numbers are relatively prime? Show the calculations that led to your conclusions.
1274 and 10505
7289 and 8029
Fill out the table described in the polynomial time algorithm for context-free language recognition from Theorem 7.16 for string baba and CFG :
Is the following formula satisfiable?
Show that P is closed under union, concatenation, and complement.
Show that NP is closed under union and concatenation.
Let . Analyze the algorithm given on page 185 to show that this language is in P.
A triangle in an undirected graph is a 3-clique. Show that TRIANGLE , where TRIANGLE .
Show that is in P.
In both parts, provide an analysis of the time complexity of your algorithm.
Show that .
Say that a language is star-closed if . Give a polynomial time algorithm to test whether a DFA recognizes a star-closed language. (Note that is not known to be in P.)
Call graphs and isomorphic if the nodes of may be reordered so that it is identical to . Let . Show that .
Let
Show that . (Note that the most obvious algorithm doesn't run in polynomial time. Hint: Try it first where is a power of 2.)
A permutation on the set is a one-to-one, onto function on this set. When is a permutation, means the composition of with itself times. Let
Show that PERM-POWER . (Note that the most obvious algorithm doesn't run within polynomial time. Hint: First try it where is a power of 2.)
Show that P is closed under the star operation. (Hint: Use dynamic programming. On input for , build a table indicating for each whether the substring for any .)
ᴬ Show that NP is closed under the star operation.
Let UNARY-SSUM be the subset sum problem in which all numbers are represented in unary. Why does the NP-completeness proof for SUBSET-SUM fail to show UNARY-SSUM is NP-complete? Show that UNARY-SSUM .
Show that if , then every language , except and , is NP-complete.
- Show that PRIMES . (Hint: For , the multiplicative group is both cyclic and of order iff is prime. You may use this fact without justifying it. The stronger statement PRIMES is now known to be true, but it is more difficult to prove.)
We generally believe that PATH is not NP-complete. Explain the reason behind this belief. Show that proving PATH is not NP-complete would prove .
Let represent an undirected graph. Also let
\begin{aligned} \operatorname {SPATH}=\left\{ \langle G, a, b, k\rangle \mid & G \text{ contains a simple path of } \\ & \text{ length at most } k \text{ from } a \text{ to } b\right\} , \end{aligned}and
Show that SPATH .
Show that LPATH is NP-complete.
Let DOUBLE-SAT . Show that DOUBLE-SAT is NP-complete.
ᴬ Let HALF-CLIQUE . Show that HALF-CLIQUE is NP-complete.
Let .
Show that .
Show that is NP-complete.
Let . Show that .
Let be a 3cnf-formula. An -assignment to the variables of is one where each clause contains two literals with unequal truth values. In other words, an -assignment satisfies without assigning three true literals in any clause.
Show that the negation of any -assignment to is also an -assignment.
Let SAT be the collection of 3 cnf-formulas that have an -assignment. Show that we obtain a polynomial time reduction from 3SAT to SAT by replacing each clause
with the two clauses
where is a new variable for each clause , and is a single additional new variable.
Conclude that is NP-complete.
A cut in an undirected graph is a separation of the vertices into two disjoint subsets and . The size of a cut is the number of edges that have one endpoint in and the other in . Let
Show that MAX-CUT is NP-complete. You may assume the result of Problem 7.26. (Hint: Show that MAX-CUT. The variable gadget for variable is a collection of nodes labeled with and another nodes labeled with , where is the number of clauses. All nodes labeled are connected with all nodes labeled . The clause gadget is a triangle of three edges connecting three nodes labeled with the literals appearing in the clause. Do not use the same node in more than one clause gadget. Prove that this reduction works.)
You are given a box and a collection of cards as indicated in the following figure. Because of the pegs in the box and the notches in the cards, each card will fit in the box in either of two ways. Each card contains two columns of holes, some of which may not be punched out. The puzzle is solved by placing all the cards in the box so as to completely cover the bottom of the box (i.e., every hole position is blocked by at least one card that has no hole there). Let . Show that PUZZLE is NP-complete.
A coloring of a graph is an assignment of colors to its nodes so that no two adjacent nodes are assigned the same color. Let
Show that 3COLOR is NP-complete. (Hint: Use the following three subgraphs.)
Let SET-SPLITTING . Show that SET-SPLITTING is NP-complete.
Consider the following scheduling problem. You are given a list of final exams to be scheduled, and a list of students . Each student is taking some specified subset of these exams. You must schedule these exams into slots so that no student is required to take two exams in the same slot. The problem is to determine if such a schedule exists that uses only slots. Formulate this problem as a language and show that this language is NP-complete.
This problem is inspired by the single-player game Minesweeper, generalized to an arbitrary graph. Let be an undirected graph, where each node either contains a single, hidden mine or is empty. The player chooses nodes, one by one. If the player chooses a node containing a mine, the player loses. If the player chooses an empty node, the player learns the number of neighboring nodes containing mines. (A neighboring node is one connected to the chosen node by an edge.) The player wins if and when all empty nodes have been so chosen. In the mine consistency problem, you are given a graph along with numbers labeling some of 's nodes. You must determine whether a placement of mines on the remaining nodes is possible, so that any node that is labeled has exactly neighboring nodes containing mines. Formulate this problem as a language and show that it is NP-complete.
ᴬ In the following solitaire game, you are given an board. On each of its positions lies either a blue stone, a red stone, or nothing at all. You play by removing stones from the board until each column contains only stones of a single color and each row contains at least one stone. You win if you achieve this objective. Winning may or may not be possible, depending upon the initial configuration. Let SOLITAIRE . Prove that SOLITAIRE is NP-complete.
Recall, in our discussion of the Church-Turing thesis, that we introduced the language . We stated, but didn't prove, that is undecidable. In this problem, you are to prove a different property of -namely, that is NP-hard. A problem is NP-hard if all problems in NP are polynomial time reducible to it, even though it may not be in NP itself. So you must show that all problems in NP are polynomial time reducible to .
A subset of the nodes of a graph is a dominating set if every other node of is adjacent to some node in the subset. Let
Show that it is NP-complete by giving a reduction from VERTEX-COVER.
- Show that the following problem is NP-complete. You are given a set of states and a collection of pairs where the are distinct strings over , and the are (not necessarily distinct) members of . Determine whether a DFA exists where for each . Here, is the state that enters after reading , starting at state . (Note that is irrelevant here.)
Let . Note that isn't required to halt on all branches. Show that is NP-complete.
- Show that if , a polynomial time algorithm exists that produces a satisfying assignment when given a satisfiable Boolean formula. (Note: The algorithm you are asked to provide computes a function; but NP contains languages, not functions. The P = NP assumption implies that SAT is in P, so testing satisfiability is solvable in polynomial time. But the assumption doesn't say how this test is done, and the test may not reveal satisfying assignments. You must show that you can find them anyway. Hint: Use the satisfiability tester repeatedly to find the assignment bit-by-bit.)
- Show that if , you can factor integers in polynomial time. (See the note in Problem 7.38.)
ᴬ Show that if , a polynomial time algorithm exists that takes an undirected graph as input and finds a largest clique contained in that graph. (See the note in Problem 7.38.)
In the proof of the Cook-Levin theorem, a window is a rectangle of cells. Show why the proof would have failed if we had used windows instead.
- Consider the algorithm MINIMIZE, which takes a DFA as input and outputs DFA . MINIMIZE = "On input , where is a DFA:
- Remove all states of that are unreachable from the start state. 2. Construct the following undirected graph whose nodes are the states of . 3. Place an edge in connecting every accept state with every nonaccept state. Add additional edges as follows. 4. Repeat until no new edges are added to : 5. For every pair of distinct states and of and every : 6. Add the edge to if is an edge of . 7. For each state , let be the collection of states . 8. Form a new DFA where (if , only one of them is in ), for every and , , and . 9. Output ."
Show that and are equivalent.
Show that is minimal-that is, no DFA with fewer states recognizes the same language. You may use the result of Problem 1.52 without proof.
Show that MINIMIZE operates in polynomial time.
For a cnf-formula with variables and clauses, show that you can construct in polynomial time an NFA with states that accepts all nonsatisfying assignments, represented as Boolean strings of length . Conclude that implies that NFAs cannot be minimized in polynomial time.
- A 2cnf-formula is an AND of clauses, where each clause is an OR of at most two literals. Let . Show that .
Modify the algorithm for context-free language recognition in the proof of Theorem 7.16 to give a polynomial time algorithm that produces a parse tree for a string, given the string and a CFG, if that grammar generates the string.
Say that two Boolean formulas are equivalent if they have the same set of variables and are true on the same set of assignments to those variables (i.e., they describe the same Boolean function). A Boolean formula is minimal if no shorter Boolean formula is equivalent to it. Let MIN-FORMULA be the collection of minimal Boolean formulas. Show that if , then MIN-FORMULA .
The difference hierarchy is defined recursively as
and
. (Here .)
For example, a language in is the difference of two NP languages. Sometimes is called DP (and may be written ). Let
Show that is complete for DP. In other words, show that is in DP and every language in DP is polynomial time reducible to .
- Let MAX-CLIQUE . Use the result of Problem 7.47 to show that MAX-CLIQUE is DP-complete.
- Let be any function where . Show that TIME contains only the regular languages.
- Call a regular expression star-free if it does not contain any star operations. Then, let . Show that is in coNP. Why does your argument fail for general regular expressions?
- This problem investigates resolution, a method for proving the unsatisfiability of cnf-formulas. Let be a formula in cnf, where the are its clauses. Let . In a resolution step, we take two clauses and in , which both have some variable occurring positively in one of the clauses and negatively in the other. Thus, and , where the and are literals. We form the new clause and remove repeated literals. Add this new clause to . Repeat the resolution steps until no additional clauses can be obtained. If the empty clause ( ) is in , then declare unsatisfiable. Say that resolution is sound if it never declares satisfiable formulas to be unsatisfiable. Say that resolution is complete if all unsatisfiable formulas are declared to be unsatisfiable.
Show that resolution is sound and complete.
Use part (a) to show that .
- Show that P is closed under homomorphism iff .
- Let be any unary language. Show that if is NP-complete, then . (Hint: Consider a polynomial time reduction from SAT to . For a formula , let be the reduced formula where variables , and in are set to the values , and 0, respectively. What happens when you apply to all of these exponentially many reduced formulas?)
In a directed graph, the indegree of a node is the number of incoming edges and the outdegree is the number of outgoing edges. Show that the following problem is NP-complete. Given an undirected graph and a designated subset of 's nodes, is it possible to convert to a directed graph by assigning directions to each of its edges so that every node in has indegree 0 or outdegree 0, and every other node in has indegree at least 1?