NP-Hard and NP-Complete
NP-Hard and NP-Complete
Complete
Polynomial-time Algorithms
• In other words,
• In other words,
• “A problem is in NP” if, given a potential solution, you can verify that it is correct or incorrect in
polynomial time.
• For instance if the problem is sorting lists, if you can verify that one list is the sorted version of
another list in polynomial time, then sorting is in NP.
• NP – efficiently verifiable
• An example of a problem which we do not know how to solve
efficiently but we can efficiently verify proofs:
• However if two sets A and B is given , we can easily check if the sums
are equal and if A and B is a partition of S.
• Note that we can compute sums efficiently.
• Eg. S={1,2,4,5} A ={2,4} and B={1,5} // Proof for YES
• A={2,5} and B={1,4} // Proof is invalid but doesn’t mean the answer
is NO
• P =efficiently solvable and NP=efficiently verifiable.
• So P=NP iff the problems that can be efficiently verified are the same
as the problems that can be efficiently solved.
NP – Hard Problem
• Minimum requirement of any efficient algorithm is that it runs in
polynomial time: O(nk ) for some constant k.
• not all problems can be solved this quickly
• NP-hard are problems, which most people believe that it cannot be
solved in polynomial time
• "at least as hard as the hardest problems in NP".
• A simple example of an NP-hard problem is the subset sum problem
• Problems that are NP-hard do not have to be elements of NP;
• indeed, they may not even be decidable.
NP-Complete
• Class of decision problems which contains the hardest problems in NP. (most difficult
NP problems)