Sei sulla pagina 1di 7

Chapter 10 Intractable Problems

In this chapter we introduce the theory of ``intractability'', that is techniques for showing problems not to be solvable in polynomial time.

10.1 The Classes

and

NP

10.1.1 Problems Solvable in Polynomial Time


A Turing machine M is said to be of time-complexity T (n) [or to have ``running time T (n) ''] if whenever M is given an input w of length n , M halts after making at most T (n) moves, regardless of whether or not M accepts. We say a language L is in class P if there is some polynomial time T (n) such that L = L( M ) for some deterministic TM M of time complexity T (n) .

10.1.2 An Example: Kruskal's Algorithm


Let us consider the problem of finding a minimum-weight spanning tree for a graph. A spanning tree is a subset of the edges such that all nodes are connected through these edges, yet there are no cycles. An example of a spanning-tree appears in fig 55. A minimum-weight spanning tree has the least possible total edge weight of all spanning trees. There is a well-known ``greedy'' algorithm, called Kruskal's algorithm, for finding a MWST.

Figure 55: A graph

1. Maintain for each node the connected component in which the node appears, using whatever edges of the tree have been selected so far. Initially, no edges are selected, so every node is then in a connected component by itself. 2. Consider the lowest-weight edge that has not yet been considered; break ties anyway you like. If this edge connects two nodes that are currently in different connected components then: - Select that edge for the spanning tree, and - Merge the two connected components involved, by changing the component number of all nodes in one of the two components to be the same as the component number of the other. If, on the other hand, the selected edge connects two nodes of the same component, then this edge does not belong in the spanning tree; it would create a cycle. 3. Continue considering edges until either all edges have been considered, or the number of edges selected for the spanning tree is one less than the number of nodes. Note that in the latter case, all nodes must be in one connected component, and we can stop considering edges.

Example 1.1 In the graph of fig 55, we first consider the edge (1,3), because it has the lowest weight, 10. since 1 and 3 are initially in different components, we accept this edge, and make 1 and 3 have the same component number, say ``component 1''. The next edge in order of weights is (2,3), with weight 12. Since 2 and 3 are in different components, we accept this edge and merge node 2 into ``component 1''. The third edge is (1,2), with weight 15. However, 1 and 2 are now in the same component, so we reject this edge and proceed to the fourth edge, (3,4). Since 4 is not in ``component 1'', we accept this edge. Now, we have three edges for the spanning tree of a 4-node graph, and so may stop. It is possible to implement this algorithm(using a computer not a TM) on a graph with m nodes and e edges in time O (m + e log e) . A simpler implementation proceeds in e rounds. A table gives the current component of each node. We pick the lowest-weight remaining edge in O (e) time, and find the components of the two nodes connected by the edge in m time. If they are in different components, merge all nodes wth those numbers in O (m) time, by scanning the table of nodes. The total time taken by this algorithm is O (e(e + m)) . This running time is polynomial in the ``size'' of the input, which we might informally take to be the sum of e and m . When we translate the above ideas to Turing Machines, we face several issues: When we study algorithms we encounter problems that ask for outputs in a variety of forms, such as a list of edges in a MWST. When we deal with Turing machines, we

may ony think of problems as languages, and th only output is yes or no, i.e. accept or reject. For instance, the MWST tree problem could be couched as: ``Given this graph G and limit W , does G have a spanning tree of weight W or less?'' That problem may seem easier to answer han the MWST problem with which we are familiar, since we don't even learn what the spanning tree is. However, in the theory of intractability. we generally want to argue that a problem is hard, not easy, and the fact that a yes-no version of a problem is hard implies that a more standard version, where a full answer must be computed, is also hard. While we might think informally of the size of a graph as the number of nodes or edges, the inout to a TM is a string over a finite alphabet. Thus, problem elements such as nodes and edges must be encoded suitably. The effect of this requirement is that inputs to Turing Machines are generaly slightly longer than the intuitive size of the input. However there are two reasons why the difference is not significant: (a) The difference between the size as a TM input string and as an informal problem inout is never more than a small factor, usually the logarithm of the input size. Thus, what can be done in polynomial time using one measure can be done in polynomial time using the other measure. (b) The length of a string representing the input is actually a more accurate measure of the number of bytes a real computer has to read to get its input. For instance, if a node is represented by an integer, then the number of bytes needed to represent that integer is proportional to the logarithm of the integer's size, and it is not ``1 byte for any node'' as we might imagine in an informal accounting for input size. Example 1.2 Let us consider a possible code for the graphs and weight limits that could be input to the MWST problem. The code has five symbols, 0,1, the left and right parentheses, and the comma. 1. Assign integers 1 through m to the nodes. 2. Begin the code with the value of m in binary and the weight limit W in binary, separated by a comma. 3. If there is an edge between nodes i and j with weight w , place (i, j , w) in the code. The integers i, j , and w are coded in binary. The order of i and j within an edge, and the order of edges within the code are immaterial. Thus, one of the possible codes for graph of Fig 55 with limit W = 40 is 100,101000(1,10,1111)(1,11,1010)(10,11,1100)(10,100,10100)(11,100,10010) If we represent inouts to the MWST problem as in Example 1.2, then an inout of length n can represent at most O ( n/logn) edges. It is possible that m , the number of nodes, could be exponential in n , if there are very few edges. However, unless the number if

edges, e , is atleast m -1, the graph cannot be connected and therefore will have no MWST, regardless of it's edges. Consequently, if the number of nodes is not atleast some fraction of n/log n , there is no need to run Kruskal's algorithm at all; we simply say ``no; there is no spanning tree of that weight.'' Thus, if we have an upper bound on the running time of Kruskal's algorithm as a function of m and e , such as the upper bound O (e(m + e)) developed above, we can conservatively replace both m and e by n and say that the running time, as a function of the input length n is O (n(n + n)) , or O(n 2 ) . We claim that in O( n 2 ) steps we can implement the version of Kruskal's algorithm described above on a multitape TM. The extra tapes are used for several jobs: 1. The input tape can hold the code for graph beginning with the number of nodes, the limit W and the edges as described in Example 1.2. 2. The second tape stores the list of nodes and their current components. This tape is O(n) in length. 3. A third tape is used to store the current least weight edge. Scanning for the lowestweight unmarked edge takes O(n) time. 4. When an edge is selected in a round, place it's two nodes on a fourth tape. Search the table of nodes and components to find the components of these two nodes. This requires O(n) time. 5. A tape can be used to hold the two components i and j , being merged. We scan the table of nodes and components and each node found to be in component i has its component number changed to j . This scan takes O(n) time.

We should thus be able to say that one round can be executed in O(n) time on a multi-tape TM. Since the number of rounds, e , is at most n , we conclude that O(n 2 ) time suffices on a multi-tape TM. Theorem 6.1 says that whatever a multitape TM can do in s steps, a single-tape TM can d in O ( s 2 ) steps. Thus, if the multitape TM takes O(n 2 ) steps, then we can construct a single-tape TM to do the same thing in 0( n 4 ) steps. Our conclusion is that the yes-no version of the MWST problem, ``does graph G have a MWST of total weight W or less,'' is in P .

10.1.3 An NP Example: The Travelling Salesman Problem


The Travelling Salesman Problem (TSP) is an example of a problem that appears to be in NP but not in P . The input to TSP is the same as to MWST, a graph with integer weights on the edges such as that of fig 55, and a weight limit W . The question asked whether graph has a ``Hamilton circuit'' of total weight at most W . Definition 1.1 A Hamilton circuit is a set of edges that connect the nodes into single cycle, with each node appearing exactly once. Note that the number of edges on a Hamilton circuit must equal the number of nodes in the graph.

10.1.4 NP -complete Problems


Definition 1.2 Let L be a language(problem) in NP . L is NP -complete if the following statements are true about L : 1. L is in NP . 2. For every language L in NP there is a polynomial-time reduction of L to L . Theorem 1.1 If P is NP-complete, P2 is in NP NP , and there is a polynomial-time 1 reduction of P to P2 , then P2 is NP-complete. 1 Theorem 1.2 If some NP-complete probelm P is in P , then P = NP .

10.1.5 The Satisfiability Problem


Definition 1.3 The boolean expressions are built from: 1. Variables whose values are boolean;i.e., they either have the value 1(true) or 0(false). 2. Binary operations and , standing for the logical AND and OR of two expressions. 3. Unary operation standing for logical negation. 4. Parentheses to group operators and operands, if necessary to alter the default precedence of operators: highest, then , and finally .

Theorem 1.3 (Cook's Theorem) SAT is NP-complete.

10.1.6 NP -Completeness of 3SAT


Definition 1.4 3SAT probelm is: Given a boolean expression E that is the product of cluases, each of which is the sum of three distict literals, is E satisfiable? Theorem 1.4 3SAT is NP-complete.

References
[1] Sudkamp A. Thomas, Languages and Machines, An Introduction to the Theory of Compute Science, Addison Wesley Publishing Company, Inc.,United States of America, 1997.

Potrebbero piacerti anche