Programming & Data Structures

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Design and Analysis of Algorithms Approximation algorithms for NP-complete problems Haidong Xue Summer 2012, at GSU.
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
1 ©D.Moshkovitz Complexity The Traveling Salesman Problem.
1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell ( )
End Topics Approximate Vertex Cover Approximate TSP Tour Computation of FFT P, NP, NP Complete, NP hard.
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Introduction to Approximation Algorithms Lecture 12: Mar 1.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
P, NP, and NP-Complete Suzan Köknar-Tezel.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
CSCE350 Algorithms and Data Structure
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Difficult Problems. Polynomial-time algorithms A polynomial-time algorithm is an algorithm whose running time is O(f(n)), where f(n) is a polynomial A.
1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Advanced Algorithm Design and Analysis (Lecture 13) SW5 fall 2004 Simonas Šaltenis E1-215b
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
CSC 413/513: Intro to Algorithms NP Completeness.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
Fundamentals of Informatics Lecture 14 Intractability and NP-completeness Bas Luttik.
LIMITATIONS OF ALGORITHM POWER
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NPC.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
Optimization/Decision Problems Optimization Problems – An optimization problem is one which asks, “What is the optimal solution to problem X?” – Examples:
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
P, NP, and NP-Complete Problems Section 10.3 The class P consists of all problems that can be solved in polynomial time, O(N k ), by deterministic computers.
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.
Algorithm Complexity By: Ashish Patel and Alex Golebiewski.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Complexity Classes.
NP-Complete Problems.
NP-completeness Ch.34.
Lecture 2-2 NP Class.
Lecture 22 Complexity and Reductions
Lecture 5 NP Class.
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 30 NP-Completeness
Chapter 34: NP-Completeness
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Approximation Algorithms
Our old list of problems
RAIK 283 Data Structures & Algorithms
ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS
Lecture 24 Vertex Cover and Hamiltonian Cycle
Presentation transcript:

Programming & Data Structures GRIFFITH COLLEGE DUBLIN Programming & Data Structures NP-Complete Problems Lecture 23

Polynomial Time (P) All of the algorithms we have looked at so far have been polynomial-time algorithms On inputs of size n, their worst-case running time is O(nk) for some constant k The question is asked can all problems be solved in polynomial time? The answer is no. There are many examples of problems that cannot be solved by any computer no matter how much time is involved There are also problems that can be solved, but not in time O(nk) for any constant k Lecture 23

Non-Polynomial Time (NP) Another class of problems are called NP problems These are problems that we have yet to find efficient algorithms in Polynomial Time for, but given a solution we can verify that solution in polynomial time Can these problems be solved in polynomial time? It has not been proved if these problems can be solved in polynomial time, or if they would require superpolynomial time This so-called P<> NP question is one which is widely researched and has yet to be settled Lecture 23

Tractable and Intractable Generally we think of problems that are solvable by polynomial time algorithms as being tractable, and problems that require superpolynomial time as being intractable. Sometimes the line between what is an ‘easy’ problem and what is a ‘hard’ problem is a fine one. For example, “Find the shortest path from vertex x to vertex y in a given weighted graph”. This can be solved efficiently without much difficulty. However, if we ask for the longest path (without cycles) from x to y, we have a problem for which no one knows a solution better than an exhaustive search Lecture 23

Deterministic v Non-Deterministic Let us now define some terms P: The set of all problems that can be solved by deterministic algorithms in polynomial time By deterministic we mean that at any time during the operation of the algorithm, there is only one thing that it can do next A nondeterministic algorithm, when faced with a choice of several options, has the power to “guess“ the right one. Using this idea we can define NP problems as, NP:The set of all problems that can be solved by nondeterministic algorithms in polynomial time. Lecture 23

Is P = NP? Obviously, any problem in P is also in NP, but not the other way around To show that a problem is in NP, we need only find a polynomial-time algorithm to check that a given solution (the guessed solution) is valid. But the idea of nondeterminism seems silly. A problem is in NP if we can ‘guess’ a solution and verify it in polynomial time!! No one has yet been able to find a problem that can be proven to be in NP but not in P Is the set P = NP? We don’t know. If it is, then there are many efficient algorithms out there just waiting to be discovered. Most researchers believe that P <> NP, but a proof remains to be shown Lecture 23

NP-Completeness NP-complete problems are set of problems that have been proved to be in NP That is, a nondeterministic solution is quite trivial, and yet no polynomial time algorithm has yet been developed. This set of problems has an additional property which does seem to indicate that P = NP If any of the problems can be solved in polynomial time on a deterministic machine, then all the problems can be solved (Cook's Theorem) It turns out that many interesting practical problems have this characteristic Lecture 23

Examples of NP-Complete Travelling Salesman Problem: Given a set of cities and distances between all pairs, find a tour of all the cities of distance less than M. Hamiltonian Cycle: Given a graph, find a simple cycle that includes all the vertices. Partition: Given a set of integers, can they be divided into two sets whose sum is equal? Integer Linear Programming: Given a linear program is there an integer solution? Vertex Cover: Given a graph and an integer N, is there a set of fewer than N vertices which touches all the edges? Lecture 23

Solving These Problems At present no algorithms exist that are guaranteed to solve any of the NP-complete problems efficiently Remember if we could find one then we could solve all the NP-Complete problems In the meantime can we find ‘adequate’ solutions? One approach is to seek an approximate solution which may not be the optimal but is close to the optimal Another approach is to focus on the average case and develop an algorithm that works for most, but not all, cases Lecture 23

Approximation Algorithms Here is an approximation algorithm for the travelling salesman problem, Approx-TSP-Tour(G, c) select a vertex r  V[G] to be a “root” vertex grow a minimum spanning tree T for G from root r using MST-Prim(G,c,r) Let L be the list of vertices visited in a preorder tree walk of T return the Hamiltonian cycle H that visits the vertices in the order L endalg This approximation if implemented correctly returns a tour whose cost is not more than twice the cost of an optimal tour Lecture 23

TSP Example b. MST c.Preorder d. Tour by preorder e. Optimum Tour f c h b d g e b. MST c.Preorder d. Tour by preorder e. Optimum Tour a. Given points Lecture 23

Summary Polynomial problems are problems for which algorithms can be found that solve the problem in polynomial time Non deterministic Polynomial problems are problems for which non-deterministic algorithms can be found NP-Complete problems are problems that are in NP, but which have the added property that if one can be solved, they all can be solved It is thought that NP-Complete problems may be insoluble using deterministic methods One approach is to develop approximation algorithm, as we did with TSP Lecture 23