This document discusses NP-hard and NP-complete problems and provides definitions and examples. It covers:
1. NP-hard problems cannot be solved in polynomial time and are at least as hard as NP-complete problems. NP-complete problems are NP-hard problems that are also in NP.
2. Non-deterministic algorithms use choices to explore all possible solutions in parallel, while deterministic algorithms explore solutions sequentially.
3. Satisfiability and the halting problem are used as examples to explain the concepts. While the halting problem is NP-hard, it is not NP-complete since it is undecidable.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
This document discusses NP-hard and NP-complete problems and provides definitions and examples. It covers:
1. NP-hard problems cannot be solved in polynomial time and are at least as hard as NP-complete problems. NP-complete problems are NP-hard problems that are also in NP.
2. Non-deterministic algorithms use choices to explore all possible solutions in parallel, while deterministic algorithms explore solutions sequentially.
3. Satisfiability and the halting problem are used as examples to explain the concepts. While the halting problem is NP-hard, it is not NP-complete since it is undecidable.
This document discusses NP-hard and NP-complete problems and provides definitions and examples. It covers:
1. NP-hard problems cannot be solved in polynomial time and are at least as hard as NP-complete problems. NP-complete problems are NP-hard problems that are also in NP.
2. Non-deterministic algorithms use choices to explore all possible solutions in parallel, while deterministic algorithms explore solutions sequentially.
3. Satisfiability and the halting problem are used as examples to explain the concepts. While the halting problem is NP-hard, it is not NP-complete since it is undecidable.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
This document discusses NP-hard and NP-complete problems and provides definitions and examples. It covers:
1. NP-hard problems cannot be solved in polynomial time and are at least as hard as NP-complete problems. NP-complete problems are NP-hard problems that are also in NP.
2. Non-deterministic algorithms use choices to explore all possible solutions in parallel, while deterministic algorithms explore solutions sequentially.
3. Satisfiability and the halting problem are used as examples to explain the concepts. While the halting problem is NP-hard, it is not NP-complete since it is undecidable.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
Download as ppt, pdf, or txt
You are on page 1of 17
1
NP HARD AND NP COMPLETE
PROBLEMS BASIC CONCEPTS The computing times of algorithms fall into two groups. Group1 consists of problems whose solutions are bounded by the polynomial of small degree. Example Binary search o(log n) , sorting o(n log n), matrix multiplication 0(n 2.81 ). 2 NP HARD AND NP COMPLETE PROBLEMS (Contd..) Group2 contains problems whose best known algorithms are non polynomial. Example Traveling salesperson problem 0(n 2 2 n ), knapsack problem 0(2 n/2 ) etc. There are two classes of non polynomial time problems 1) NP- hard 2) NP-complete A problem which is NP complete will have the property that it can be solved in polynomial time iff all other NP complete problems can also be solved in polynomial time. 3 NP HARD AND NP COMPLETE PROBLEMS (Contd..) If an NP-hard problem can be solved in polynomial time, then all NP-complete problems can be solved in polynomial time. All NP-complete problems are NP-hard, but all NP-hard problems are not NP-complete. The class of NP-hard problems is very rich in the sense that it contain many problems from a wide variety of disciplines. 4 DETERMINISTIC and NONDETERMINISTIC ALGORITHMS Algorithms with the property that the result of every operation is uniquely defined are termed deterministic. Such algorithms agree with the way programs are executed on a computer. In a theoretical framework we can allow algorithms to contain operations whose outcome is not uniquely defined but is limited to a specified set of possibilities. 5 Deterministic and Nondeterministic algorithms (contd..) The machine executing such operations are allowed to choose any one of these outcomes subject to a termination condition. This leads to the concept of non deterministic algorithms. To specify such algorithms in SPARKS, we introduce three statements i) choice (s) arbitrarily chooses one of the elements of the set S. ii) failure . Signals an unsuccessful completion. iii) Success : Signals a successful completion. 6 Deterministic and Nondeterministic algorithms (contd..) Whenever there is a set of choices that leads to a successful completion then one such set of choices is always made and the algorithm terminates. A nondeterministic algorithm terminates unsuccessfully if and only if there exists no set of choices leading to a successful signal. A machine capable of executing a non deterministic algorithm is called a non deterministic machine. While non-deterministic machines do not exist in practice they will provide strong intuitive reason to conclude that certain problems cannot be solved by fast deterministic algorithms. 7 Example of a non deterministic algorithm // The problem is to search for an element x // // Output j such that A(j) =x; or j=0 if x is not in A // j choice (1 :n ) if A(j) =x then print(j) ; success endif print (0) ; failure complexity 0(1); - Non-deterministic decision algorithms generate a zero or one as their output. - Deterministic search algorithm complexity. O(n)
8 Deterministic and Nondeterministic algorithms (contd..) Many optimization problems can be recast into decision problems with the property that the decision problem can be solved in polynomial time iff the corresponding optimization problem can . EXAMPLE : [0/1 knapsack] : The decision is to determine if there is a 0/1 assignment of values to x i 1s i s n such that p i x i > R, and w i x i s M, R, M are given numbers p i , w i >0, 1s i s n. It is easy to obtain polynomial time non deterministic algorithms for many problems that can be deterministically solved by a systematic search of a solution space of exponential size. 9 SATISFIABILITY Let x 1 ,x 2 ,x 3 .x n denotes Boolean variables. _ Let x i denotes the relation of x i . A literal is either a variable or its negation. A formula in the prepositional calculus is an expression that can be constructed using literals and the operators and A or v. A clause is a formula with at least one positive literal. The satiability problem is to determine if a formula is true for some assignment of truth values to the variables. 10 SATISFIABILITY (Contd..) It is easy to obtain a polynomial time non determination algorithm that terminates successfully if and only if a given prepositional formula E(x 1 ,x 2 x n ) is satiable. Such an algorithm could proceed by simply choosing (non deterministically) one of the 2 n
possible assignments of truth values to (x 1 ,x 2 x n ) and verify that E(x 1 ,x 2 x n ) is true for that assignment. 11 Definition of the classes NP-hard and NP- complete P is the set of all decision problems solvable by a deterministic algorithm in polynomial time. NP is the set of all decision problems solvable by a nondeterministic algorithm in polynomial time. Since deterministic algorithm are a special case of non deterministic ones, we can conclude that P_NP. The most famous unsolved problem in computer science is whether P = NP or P = NP. Is it possible that for all the problems in NP their exist polynomial time deterministic algorithms which have remained undiscovered ? 12 Definition of the classes NP-hard and NP- complete (contd..) In considering this problem S.COOK formulated the following question : Is there any single problem in NP such that if we showed it to be in P then that would imply that P = NP. COOKs Theorem : Satisfiability is in P if and only if P = NP. 13 Definition of the classes NP-hard and NP- complete (contd..) Definition : Reducibility Let L 1 and L 2 be problems. L 1 reduces to L 2 (L 1 o L 2 ) if and only if there is a deterministic polynomial time algorithm to solve L 1 that solves L 2 in polynomial time. If L 1 o L 2 and L 2 o L 3 then L 1 o L 3 . Definition : NP-Hard Problem : A problem L is NP- hard if any only if satisfiability reduces to L. 14 Definition of the classes NP-hard and NP- complete (contd..) Definition : NP-complete Problem : A problem L is NP-complete if and only if L is NP-hard and L NP. There are NP-hard problems that are not NP-complete. Example : Halting problem is NP-hard decision problem, but it is not NP-complete. Halting Problem : To determine for an arbitrary deterministic algorithm A and an input I whether algorithm A with input I ever terminates (or enters an infinite loop). 15 Halting problem is not NP-complete; but NP-hard Halting problem is un-decidable. - Hence there exists no algorithm to solve this problem. - So, it is not in NP. - So, it is not NP-complete. Halting problem is NP-hard To show that Halting problem is NP-hard, we show that satisfiability is o halting problem. For this let us construct an algorithm A whose input is a prepositional formula X. - Suppose X has n variables. - Algorithm A tries out all 2 n possible truth assignments and verifies if X is satisfiable. 16 Halting problem is NP-hard (Contd..) - If it is then A stops. - If X is not satisfiable, then A enters an infinite loop. - Hence A halts on input iff X is satisfiable. - If we had a polynomial time algorithm for the halting problem, then we could solve the satisfiability problem in polynomial time using A and X as input to the algorithm for the halting problem . - Hence the halting problem is an NP-hard problem which is not in NP. - So it is not NP-complete.
17 SOME SIMPLIIFIED NP-HARD PROBLEMS (ii)Generating optimal code for a parallel assignment statement is NP-hard, - however if the expressions are restricted to be simple variables, then optimal code can be generated in polynomial time. (iii)Generating optimal code for level one directed a- cyclic graphs is NP-hard but optimal code for trees can be generated in polynomial time. (iv)Determining if a planner graph is three colourable is NP- Hard - To determine if it is two colorable is a polynomial complexity problem. (We only have to see if it is bipartite)
Title Integration Test - Refurbishment Process - Replace & Repair (PM - MM Integration) Author Arfan Sutiyono 1 of 9 Document 444523796.doc Date 11 Nov 2009