DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Similar documents
Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

NP-Completeness. NP-Completeness 1

1. Introduction Recap

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP-Complete Reductions 1

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Limitations of Algorithm Power

ECS122A Handout on NP-Completeness March 12, 2018

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

NP Completeness and Approximation Algorithms

NP-Completeness. Until now we have been designing algorithms for specific problems

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

NP-Complete problems

1.1 P, NP, and NP-complete

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Computational Complexity

NP Complete Problems. COMP 215 Lecture 20

Introduction to Complexity Theory

Essential facts about NP-completeness:

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

NP-completeness. Chapter 34. Sergey Bereg

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

CMSC 441: Algorithms. NP Completeness

Polynomial-time reductions. We have seen several reductions:

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

NP-Completeness. NP-Completeness 1

VIII. NP-completeness

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

The P-vs-NP problem. Andrés E. Caicedo. September 10, 2011

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

CS 350 Algorithms and Complexity

CS 583: Algorithms. NP Completeness Ch 34. Intractability

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

Design and Analysis of Algorithms

CS 350 Algorithms and Complexity

Notes for Lecture 21

P, NP, NP-Complete. Ruth Anderson

Correctness of Dijkstra s algorithm

NP-problems continued

DAA 8 TH UNIT DETAILS

CSC 1700 Analysis of Algorithms: P and NP Problems

Formal definition of P

Polynomial-time Reductions

Instructor N.Sadagopan Scribe: P.Renjith

SAT, NP, NP-Completeness

Chapter 34: NP-Completeness

P vs. NP. Data Structures and Algorithms CSE AU 1

The Complexity Classes P and NP. Andreas Klappenecker [partially based on slides by Professor Welch]

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Lecture 18: P & NP. Revised, May 1, CLRS, pp

Spring Lecture 21 NP-Complete Problems

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

Comparison of several polynomial and exponential time complexity functions. Size n

P, NP, NP-Complete, and NPhard

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

BBM402-Lecture 11: The Class NP

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

NP and NP Completeness

Algorithms Design & Analysis. Approximation Algorithm

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

NP, polynomial-time mapping reductions, and NP-completeness

NP-Completeness. Subhash Suri. May 15, 2018

CS21 Decidability and Tractability

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

1 Primals and Duals: Zero Sum Games

Lecture 4: NP and computational intractability

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Computational Complexity

Class Note #20. In today s class, the following four concepts were introduced: decision

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Problem Complexity Classes

NP-Complete Problems and Approximation Algorithms

CS 241 Analysis of Algorithms

COP 4531 Complexity & Analysis of Data Structures & Algorithms

1 Computational problems

Turing Machines and Time Complexity

CS/COE

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

The P = NP Problem Bristol Teachers Circle, June P.D.Welch, University of Bristol

Problems and Solutions. Decidability and Complexity

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

Chapter 2 : Time complexity

Automata Theory CS Complexity Theory I: Polynomial Time

Review of unsolvability

Graph Theory and Optimization Computational Complexity (in brief)

Lecture 15 - NP Completeness 1

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

NP-Complete Problems. More reductions

NP and NP-Completeness

CSCI3390-Lecture 16: NP-completeness

Data Structures in Java

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

ECS 120 Lesson 24 The Class N P, N P-complete Problems

Lecture 19: Finish NP-Completeness, conp and Friends

INTRO TO COMPUTATIONAL COMPLEXITY

Transcription:

DESIGN AND ANALYSIS OF ALGORITHMS Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS http://milanvachhani.blogspot.in

COMPLEXITY FOR THE IMPATIENT You are a senior software engineer in a large software house. A demanding customer has asked for a program to solve a new, seemingly difficult, problem. On realizing that other customers also may come up with similar requirements, your manager has entrusted you the job of finding a most efficient general algorithm for the problem. After spending considerable time and effort on the job, you find that you are not able to find an efficient algorithm. What are the possibilities and what could you do?

In the above list of possibilities, a significant departure in attitude come at points marked with letter N. How do we decide that point?

In the previous chapters we have encountered a variety of algorithms, having efficiencies ranging over a wide spectrum. Even with the same basic algorithm, we noticed that running times can be reduced significantly by some adjustment of the algorithm. We noted this in case of the bogosort.c and bogosorti.c programs given in Chapters 1 and 4, where a small modification in the algorithm reduced the expected run times from O(n!) to O(n 2 ). Our studies in the later chapters showed us that the best running time we can expect for known sorting algorithm is O(n log(n)). This raises a question in our mind- Is this the minimum time that any sorting algorithm can achieve?" Note that here the question is not about a particular algorithm, but rather any algorithm whatsoever for sorting a given array. In other words, the question is about the problem itself-"does the sorting problem allow an algorithm having time less than O(n log(n))?"

Thus our focus now turns from a particular algorithm to a class of problems, e.g. sort problems. The range of conceptual abstractness of investigations involved is shown in next Figure. For example, suppose we have not developed efficient sorting algorithms like Quick-sort or Merge-sort and did all our sorting by an algorithm like bogosorti.c. Now suppose some clever researcher proves a lowerbound of O(n log(n)) on the running time of the class of sorting problems (i.e. all the possible sorting problem instances), then a host of developers will get busy trying to develop more efficient sorting algorithms, because now it is known that such an algorithm is possible. The above observations also points to the importance of finding the Lower bound on the expected running times of a class of problems.

Our major concern arises out of some of the results that we have already seen in the previous Chapters 4 and 14. Referring to previous figure, where we have plotted running times of algorithms with different behaviours, which one is the "odd-man-out"? Obviously the algorithm with run-time of 2 n is the" oddman-out". Even if the polynomial terms like n 4 are multiplied by large constant factors, say 10 3, their runtimes will still be much less than those of the algorithm with 2 n time. We are concerned about such difficult or hard algorithms. If we come across problems for which the only known algorithms are of such hard type, we should study those problems more closely. That is why we study Complexity classes of problems, with a view to categorize problems according to the timing behaviour of the best algorithms to solve them. The tentative situation observed till now is shown in next figure.

Computer scientists found that some problems are well behaved enough for the algorithms which solved them had polynomial time characteristics. Such problems were said to be tractable and were considered to be in a set called P, standing for polynomial time solvable problems. Others were said to be non-tractable. Soon it was found that matter was not that simple and clear-cut and required deeper study. After that rather rough and ready exposure to tractability, we present here, quick and terse elucidation of the current understanding about problem complexity which is accepted by most of the researchers.

Polynomial Time and Decision Problems In view of the considerations for run-times put forward above and in Chapters 4 and 14, we use the Polynomial- time as the cut-off for efficiency of algorithms and complexity of problem classes. That part is clear enough, but what about problems which are beyond that cutoff? To make our discussion simple, we take up for discussion a limited, but important class of problems, called Decision Problems. Decision problems have as their output either 1 or 0 (or "yes" or "no"). Some examples are:

Does a given graph G have an Euler tour? Does a text S contain a pattern R? Does an instance of 0/1 Knapsack have a solution with profit at least K? Does a graph G have an MST with weight at most K? Does a given set of n cities, in a TSproblem, have a tour of length less than a limit m? Note that in such problems we are not asking for a particular solution, but whether a solution exists at all. The algorithm to get the yes/no answer may or may not find the actual solution.

Problems and Languages The algorithm which solves a particular decision problem will be given the problem instance in form of a question, as concisely as possible and possibly coded in some language. For example, the decision problem "Does a text S contain a pattern R?" may be given to the algorithm as "in('this is good.', 'is')?" Thus a problem is expressed in form of a sentence or a string in some language. The given string may not result in a "yes" answer. Our definition of a language is slightly narrower. A language L is a set of strings x defined over some alphabet L. Every decision algorithm A defines a language L. A language L is the set consisting of every string x such that A outputs "yes" on input x. We say "A accepts x" if that is so. Expressed in symbolic form: For example, if an algorithm A determines whether or not a given graph G has an Euler tour, then the language L for A is all graphs with Euler tours.

Complexity Classes and Class P A complexity class is a collection of languages satisfying certain criteria. P is the complexity class consisting of all languages that are accepted by polynomial-time algorithms. For each language L in P there is a polynomial time decision algorithm A for L. If n= x, then x Є L, A runs in p(n) time on input x, the function p(n) is some polynomial in n. What about problems which are not in P? Consider the decision form of the Traveling Salesman problem: "Given a set of n cities, does it have a tour of length less than a limit m?"

There is no known polynomial time algorithm for solving this problem. However, suppose we find for a particular instance of this problem, that the answer for that instance is "yes." We are skeptical and would like to ensure correctness of the result by checking that the tour, which was basis for that answer, has indeed the required properties. It would then be a simple matter of computing its length and comparing that quantity to the given bound m. This verification procedure will have a polynomial time complexity. This idea of polynomial time verifiability is being described by the class NP. Note that polynomial time verifiability does not imply polynomial time solvability. Note well that NP stands for "Non-deterministic Polynomial-time" and not for "Non-Polynomial-time".

Complexity Class NP-1st Definition We say that an algorithm is non-deterministic if it uses some operation like: choose(v): chooses a value or a symbol v. Such an operation may also be used to choose an entire string y, with Y choices. How this choice is made is not specified. For example, it may be done by a random select out of a finite set. As if by some magic, which is out of purview of the algorithm, we get the chosen value. We say that a non-deterministic algorithm A accepts a string x if there exists some sequence of choose() operations that causes A to output "yes" on input x. NP is the complexity class consisting of all languages accepted by polynomial-time non-deterministic algorithms.

Example: Problem: Decide if a TS has a tour of length at most K. Algorithm: 1) Non-deterministically choose a set T of n edges, 2) Test that T forms a valid tour 3) Test that T has length at most K Analysis: Testing takes O(n) time, so this algorithm runs in polynomial time. Complexity Class NP - 2nd Definition: We say that an algorithm B verifies the acceptance of a language L iff, for all x in L, there exists a certificate y such that B outputs "yes on input (x, y). We have already had a rather imprecise glimpse of what a certificate looks like in our bogosort. c program, in form of the sorted () function. NP is the complexity class consisting of all languages verified by polynomial-time algorithms. Note that verification of a candidate solution is easier than computing the solution itself.

Example: We take the following problem as an example for the alternate definition of the class NP. Problem: Decide if a TS problem has a tour of length K or less. Verification Algorithm: 1) Use as a certificate, y, a set T of n edges, 2) Test that T forms a valid tour 3) Test that T has length at most K Analysis: Generation and Verification takes O(n) time, so this algorithm runs in polynomial time. At this stage we can say that: We know that P NP. The major open question is P = NP? Most researchers believe that P NP Generally accepted relationship between class P and class NP. P corresponds to the Tractable class, but NP is not Prepared necessarily by same : Dr. Milan as non-tractable Vachhani

Equivalence of the Two Definitions of NP: We show the Equivalence of the two definitions of NP by demonstrating how to implement an algorithm of one type in terms of the one of the other type. Suppose A is a non-deterministic algorithm. Let y be a certificate consisting of all the outcomes of the choose() steps that A uses. We can create a verification algorithm B' that uses y instead of A s choose steps. If A accepts x, then there is a certificate y that allows us to verify this (namely, the choose steps A made). If A runs in polynomialtime, so does this verification algorithm B'. Please see Figure.

Suppose B is a verification algorithm. Non-deterministically choose a certificate y and run B on y. If B runs in polynomialtime, so does this non-deterministic algorithm A. Please see Figure.

Polynomial Transformations We have to find a method to compare relative difficulty of solving various classes of problems. This is done by transforming a problem into another, by an auxiliary Polynomial-time algorithm. This is also called reduction technique. The main technique used for demonstrating that two problems are related is that of "reducing" one to the other, by giving a transformation that maps any instance of the first problem into an equivalent instance of the second. Such a transformation provides the means for converting any algorithm that solves the second problem into a corresponding algorithm for solving the first problem. In other words, if we have an algorithm solving the second problem, we can also solve the first problem. More specifically, if we have a polynomial time reduction from one problem to another, this ensures that any polynomial time algorithm for the second problem can be converted into a corresponding polynomial time algorithm for the first problem.

Cook in his 1971 paper showed that one particular problem in NP, called the "satisfiability problem, (see CIRCUIT-SAT below), has the property that every other problem in NP can be polynomially reduced to it. If the CIRCUIT-SAT problem can be solved with a polynomial time algorithm, then so can every problem in NP, and if any problem in NP is intractable, then the CIRCUIT-SAT problem also must be intractable. Thus CIRCUIT-SAT problem is the hardest problem in NP. Many other problems in NP are found to be as hard as CIRCUIT-SAT, and a class of problems, NP- Complete, is defined which contain them. Formally,

NP Problems A problem (language) L is NP-Hard if every problem in NP can be reduced to L in polynomial time. That is, for each language L' in NP, we can take an input x from L', transform it in polynomial time to an input x' for L such that x is in L' iff x' is in L. In other words, the problem is at least as difficult as all other problems in NP. L is NP-Complete if it's in NP and is NP-Hard. Please see Figure.

CIRCUIT-SAT is in NP An Interesting problem, known as CIRCUIT-SAT (or, simply SAT), is studied as an example of a NP problem. A Boolean circuit is a circuit of AND, OR, and NOT gates. For example, a simple logic circuit is shown in Figure. The CIRCUIT-SAT problem is to determine if there is an assignment of 0's and 1's to a given Boolean circuit's inputs so that the circuit outputs 1. The problem can also be enunciated in terms of Boolean expressions, e.g. f = a v b ^ c.

Non-deterministically choose a set of inputs to the circuit and then test the circuit s output. As this can be done in polynomial time, CIRCUIT-SAT is in NP. Cook-Levin theorem says that CIRCUIT-SAT is in NP- Complete. Some NP-Complete Problems Some of the well studied NP-Complete problems are: CNF-SAT and 3SAT Vertex Cover Clique Hamiltonian Cycle Set Cover SubsetSum 0/1 Knapsack Traveling Salesman

Is P equal to NP? Most of the present day researchers believe that P is a proper subset of NP, i.e. P NP. Implication of this belief is that the NPComplete problems are the hardest in NP. This is because if we could solve a NP-Complete problem in polynomial time, we could solve every problem in NP in polynomial time. That is, if an NP-Complete problem is solvable in polynomial time, then P = NP. Significance of a problem being NP-complete: Since so many people have attempted, without success, to find polynomial-time solutions to NP-Complete problems, showing your problem is NP-Complete is equivalent to showing that a lot of smart people have worked on your problem and found no polynomial-time algorithm. If a polynomial-time algorithm is known for one NP-Complete problem, then there is a polynomial-time algorithm for every NP-Complete problem. An exponential lower bound for such a problem has never been shown. If difficult instances of an NP-Complete problem arise in practice, then approximation schemes with bounds on the quality of the solution are needed.

VIDEO REFERENCES P, NP, NPC, NPH https://www.youtube.com/watch?v=f7u7uk6iiu4 https://www.youtube.com/watch?v=htlypzgpohc https://www.youtube.com/watch?v=1qehnctsveu https://www.youtube.com/watch?v=gq4k5hhiise https://www.youtube.com/watch?v=vgckklmcgei

THANK YOU Dr. Milan Vachhani Assistant Professor, Sunshine Group of Institutions, Rajkot milan.vachhani@gmail.com http://milanvachhani.blogspot.com