SlideShare a Scribd company logo
1 of 17
NP-Hard
By: Jesal Joshi
Joshi Jesal
Decision and Optimization Problems
• Decision Problem: computational problem
with intended output of “yes” or “no”, 1 or 0
• Optimization Problem: computational
problem where we try to maximize or
minimize some value
• Introduce parameter k and ask if the optimal
value for the problem is a most or at least k.
Turn optimization into decision
Joshi Jesal
Review: P and NP
• What do we mean when we say a problem
is in P?
– A: A solution can be found in polynomial time
• What do we mean when we say a problem
is in NP?
– A: A solution can be verified in polynomial time
• What is the relation between P and NP?
– A: P  NP, but no one knows whether P = NP
Joshi Jesal
Commonly Believed Relationship
between P and NP
NPP
Joshi Jesal
Reductions
Algo to Decide A
Algo. Decide BReduction Algoa b
yes
No
Given two sets A and B
– Procedure is called polynomial-time reduction algorithm and it provides us
with a way to solve problem A in polynomial time
-Also known as Turing reduction
- Given an instance a of A, use a polynomial-time reduction algorithm to
transform it to an instance b of B
- Run the polynomial-time decision algorithm on instance b of B
-Use the answer b of a as the answer for b
Joshi Jesal
Satisfiability(SAT)
• I/P : Boolean formula
• O/P : Is formula satisfiable?
SAT Є NP
Proof : Assignment to variables
Verifier: Uses these assignments and checks
that the formula evaluates to true (T).
Joshi Jesal
COOK’s Theorem
• If SAT has an efficient algorithm then so does
other problems in NP.
There is an efficient algo. for SAT
↓
There is an efficient algo for all problems in NP.
Joshi Jesal
NP Hard
• A problem A is NP-hard if and only if
satisfiability reduces to A (satisfiability α A).
• A problem A is NP-complete if and only if A is
NP-hard and A Є NP.
Joshi Jesal
Relationship among P,NP,NP-Complete
and NP-Hard
NP
P
NP-Complete
Joshi Jesal
Vertex Cover is NP-Hard
• What is Vertex Cover ?
Vertex Cover in a graph G is a set of vertices
such that every edge has atleast one end point
in it.
Ex.
Vertex Cover (Search) converted to VC(decision)
Joshi Jesal
• To prove VC is NPH, We are using
Independent-Set for Turing Reducibility.
i.e IS ≤T VC , IS is turing reducible to VC
Assume that there is a poly-time algo for VC
Construct a poly. Algo. For Independent Set.
Vertex Cover is NP-Hard contd..
Joshi Jesal
Independent Set
• Given a graph G=(V,E) , a subset U of V is called
independent set if
for all u1,u2 Є U and {u1,u2} Є Edge
• Search Problem of IS:
I/P :
O/P:
• Decision Problem of IS :
I/P :
O/P:
Joshi Jesal
Relation between VC and IS
VC- May
have Edge
IS-No Edges
Joshi Jesal
Take G, K (Want to determine if G has an independent set of size K)
G’, K’
VC
Yes
Yes
No
No
V(G’) =V(G) , n=IV(G)I
E(G’) =E(G)
K’= n-k
Algo for independent Set
Joshi Jesal
• Hence , Given a Polynomial time algo for VC,
We constructed for Independent set
So,VC is NP-Hard.
Joshi Jesal
• There are NP-Hard problems that are not NP-
Complete.
• Only decision problem can be NP-Complete,
Optimization problems can not be NP-
Complete.
• So, there exist NP-Hard Problem that are not
NP-Complete.ex. Halting problem
• NP-hard Problem that do not belong tp set NP
are harder to solve
ex. Optimization is hard then to decision
Joshi Jesal
QUERIES??..
Joshi Jesal

More Related Content

Viewers also liked (9)

Las clases P NP y NP completo
Las clases P NP y NP completoLas clases P NP y NP completo
Las clases P NP y NP completo
 
P versus NP
P versus NPP versus NP
P versus NP
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Np hard
Np hardNp hard
Np hard
 
Introduction to NP Completeness
Introduction to NP CompletenessIntroduction to NP Completeness
Introduction to NP Completeness
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 
np complete
np completenp complete
np complete
 
NP completeness
NP completenessNP completeness
NP completeness
 
Np complete
Np completeNp complete
Np complete
 

Similar to Np hard (13)

PNP.pptx
PNP.pptxPNP.pptx
PNP.pptx
 
PNP.pptx
PNP.pptxPNP.pptx
PNP.pptx
 
Np completeness
Np completenessNp completeness
Np completeness
 
NP-Completeness-myppt.pptx
NP-Completeness-myppt.pptxNP-Completeness-myppt.pptx
NP-Completeness-myppt.pptx
 
AA ppt9107
AA ppt9107AA ppt9107
AA ppt9107
 
Ads unit 3 ppt
Ads unit 3 pptAds unit 3 ppt
Ads unit 3 ppt
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6
 
UNIT-V.ppt
UNIT-V.pptUNIT-V.ppt
UNIT-V.ppt
 
Universal Approximation Theorem
Universal Approximation TheoremUniversal Approximation Theorem
Universal Approximation Theorem
 
lect5-1.ppt
lect5-1.pptlect5-1.ppt
lect5-1.ppt
 
Np complete
Np completeNp complete
Np complete
 
lecture 30
lecture 30lecture 30
lecture 30
 

Np hard

  • 2. Decision and Optimization Problems • Decision Problem: computational problem with intended output of “yes” or “no”, 1 or 0 • Optimization Problem: computational problem where we try to maximize or minimize some value • Introduce parameter k and ask if the optimal value for the problem is a most or at least k. Turn optimization into decision Joshi Jesal
  • 3. Review: P and NP • What do we mean when we say a problem is in P? – A: A solution can be found in polynomial time • What do we mean when we say a problem is in NP? – A: A solution can be verified in polynomial time • What is the relation between P and NP? – A: P  NP, but no one knows whether P = NP Joshi Jesal
  • 4. Commonly Believed Relationship between P and NP NPP Joshi Jesal
  • 5. Reductions Algo to Decide A Algo. Decide BReduction Algoa b yes No Given two sets A and B – Procedure is called polynomial-time reduction algorithm and it provides us with a way to solve problem A in polynomial time -Also known as Turing reduction - Given an instance a of A, use a polynomial-time reduction algorithm to transform it to an instance b of B - Run the polynomial-time decision algorithm on instance b of B -Use the answer b of a as the answer for b Joshi Jesal
  • 6. Satisfiability(SAT) • I/P : Boolean formula • O/P : Is formula satisfiable? SAT Є NP Proof : Assignment to variables Verifier: Uses these assignments and checks that the formula evaluates to true (T). Joshi Jesal
  • 7. COOK’s Theorem • If SAT has an efficient algorithm then so does other problems in NP. There is an efficient algo. for SAT ↓ There is an efficient algo for all problems in NP. Joshi Jesal
  • 8. NP Hard • A problem A is NP-hard if and only if satisfiability reduces to A (satisfiability α A). • A problem A is NP-complete if and only if A is NP-hard and A Є NP. Joshi Jesal
  • 9. Relationship among P,NP,NP-Complete and NP-Hard NP P NP-Complete Joshi Jesal
  • 10. Vertex Cover is NP-Hard • What is Vertex Cover ? Vertex Cover in a graph G is a set of vertices such that every edge has atleast one end point in it. Ex. Vertex Cover (Search) converted to VC(decision) Joshi Jesal
  • 11. • To prove VC is NPH, We are using Independent-Set for Turing Reducibility. i.e IS ≤T VC , IS is turing reducible to VC Assume that there is a poly-time algo for VC Construct a poly. Algo. For Independent Set. Vertex Cover is NP-Hard contd.. Joshi Jesal
  • 12. Independent Set • Given a graph G=(V,E) , a subset U of V is called independent set if for all u1,u2 Є U and {u1,u2} Є Edge • Search Problem of IS: I/P : O/P: • Decision Problem of IS : I/P : O/P: Joshi Jesal
  • 13. Relation between VC and IS VC- May have Edge IS-No Edges Joshi Jesal
  • 14. Take G, K (Want to determine if G has an independent set of size K) G’, K’ VC Yes Yes No No V(G’) =V(G) , n=IV(G)I E(G’) =E(G) K’= n-k Algo for independent Set Joshi Jesal
  • 15. • Hence , Given a Polynomial time algo for VC, We constructed for Independent set So,VC is NP-Hard. Joshi Jesal
  • 16. • There are NP-Hard problems that are not NP- Complete. • Only decision problem can be NP-Complete, Optimization problems can not be NP- Complete. • So, there exist NP-Hard Problem that are not NP-Complete.ex. Halting problem • NP-hard Problem that do not belong tp set NP are harder to solve ex. Optimization is hard then to decision Joshi Jesal