Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 P and NP. 2 Introduction The Traveling Salesperson problem and thousands of other problems are equally hard in the sense that if we had an efficient.

Similar presentations


Presentation on theme: "1 P and NP. 2 Introduction The Traveling Salesperson problem and thousands of other problems are equally hard in the sense that if we had an efficient."— Presentation transcript:

1 1 P and NP

2 2 Introduction The Traveling Salesperson problem and thousands of other problems are equally hard in the sense that if we had an efficient algorithm for any one of them, we would have efficient algorithms for all of them. Such an algorithm has never been found, but it’s never been proven that one is not possible. This kind of problems are called NP-complete problems and are introduces in this chapter. A problem for which an efficient algorithm is not possible is said to be intractable..

3 3 Interacability A problem in computer science is intracable if a computer has difficulty solving it that is it is impossible to solve it with a polynomial-time algorithm. Polynomial-time algorithm is one whose worst-case time complexity is bounded above by a polynomial function of its input size. For a problem to be intractable there must be no polynomial-time algorithm that solves it.

4 4 Interacability(Contd..) Furthermore, many algorithms whose worst-case time complexities are not polynomials have efficient running times for many actual instances. This is the case for many backtracking and branch-and-bound algorithms. There are three general categories of problems as far as intractability is concerned:  Problems for which polynomial-time algorithms have been found  Problems that have been proven to be intractable  Problems that have not been proven to be intractable, but for which polynomial-time algorithms have never been found

5 5 The Three General Problem Categories We have three general categories in which problems can be grouped as far as intractability is concerned. 1. Problems for Which Polynomial-Time Algorithms Have Been Found Any problem for which we have found a poly-time algorithm Sorting, searching, matrix multiplication, chained matrix multiplication, shortest paths, minimal spanning tree, etc.

6 6 2.Problems That Have Been Proven to Be Intractable There are two types of problems in this category. The first type is problems that require a non-polynomial amount of output such as the problem of determining all Hamiltonian Circuits. If there was an edge from every vertex to every other vertex, there would be (n - 1)! such circuits. To solve the problem, an algorithm would have to output all of these circuits, which means that our request is not reasonable. It is straightforward to recognize that a non- polynomial amount of output is being requested, and once we recognize this, we realize that we are simply asking for more information than we could possibly use. That is, the problem is not defined realistically.

7 7 2.Problems That Have Been Proven to Be Intractable (Contd..) The second type of those that produce a reasonable amount of output, but the processing time is just too long. The most well-known of these is the Halting problem. In this problem we take as input any algorithm and any input to that algorithm, and decide whether or not the algorithm will halt when applied to that input.

8 8 3. Problems That Have Not Been Proven to Be Intractable Problems That Have Not Been Proven to Be Intractable but for Which Polynomial-Time Algorithms Have Never Been Found This category includes any problem for which a polynomial-time algorithm has never been found, but yet no one has ever proven that such an algorithm is not possible. Many problems belong in the category such as 0-1 Knapsack, Traveling Salesperson, m-coloring, Hamiltonian Circuits. In general, any problem that we had to solve using backtracking or bounded backtracking falls into this category

9 9 The Theory of NP It will be more convenient to develop this theory restricting ourselves to decision problems Problems that have a yes/no answer We can always convert non-decision problems into decision problems In 0/1 Knapsack instead of just asking for the optimal profit, we can instead ask if the optimal profit exceeds some number In graph coloring instead of just asking the minimal number of colors we can instead ask if the minimal number is less than m

10 10 The Sets P and NP The set P is the set of all decision problems that can be solved by polynomial-time algorithms. All decision problems for which we have found poly-time algorithms are certainly in P. For example, the problem of determining whether a key is present in an array, the problem of determining whether a key is present in a sorted array, and the decision problems corresponding to the optimization problems.

11 11 The Sets P(Contd..) Can decision problem for which we have not found a polynomial-time algorithm also be in P? An example is the Traveling Salesperson problem. Even though no one has ever created a polynomial-time algorithm that solves this problem, no one has ever proven that it cannot be solved with a polynomial time algorithm. Therefore, it could possibly be in P. To know that a decision problem is not in P, we have to prove that it is not possible to develop a polynomial-time algorithm for it.

12 12 The set NP : The set NP is the set of all decision problems that can be solved by a polynomial-time non-deterministic algorithm. For a decision problem to be in NP there must be an algorithm that does the verification in polynomial time. Because this is the case for the Traveling Salesperson Decision problem, that problem is in NP. This does not mean that we necessarily have a polynomial-time algorithm that solves the problem. A poly-time non-deterministic algorithm is an algorithm that is broken into 2 stages: Guessing (non-deterministic) stage Verification (deterministic) stage Where the verification stage can be accomplished in polynomial-time

13 13 NP-Complete Problems To date, no one has found a polynomial-time algorithm for the Traveling Salesperson problem. On the other hand, no one has been able to prove that no polynomial- time algorithm exists for it. How, then, can we argue persuasively that the Traveling Salesperson problem and many problems in NP are “intractable”? Instead, we offer an argument that is slightly weaker but also compelling. We show that the recognition version of the Traveling Salesperson problem, and scores of other NP problems, are the hardest problems in the class NP in the following sense: if there is a polynomial-time algorithm for any one of these problems, then there is a polynomial-time algorithm for every problem in NP. Problems in NP with this property are called NP- complete.

14 P And NP Summary P = set of problems that can be solved in polynomial time NP = set of problems for which a solution can be verified in polynomial time P  NP


Download ppt "1 P and NP. 2 Introduction The Traveling Salesperson problem and thousands of other problems are equally hard in the sense that if we had an efficient."

Similar presentations


Ads by Google