Aditya Engineering College (A) : Unit-V
Aditya Engineering College (A) : Unit-V
UNIT-V
NP-Hard and NP-Complete problems
By
M.Raja Babu
Associate Professor
Dept of Information Technology
Aditya Engineering College(A)
Surampalem.
Aditya Engineering College (A)
UNIT-V
• Basic concepts
• non-deterministic algorithms
• NP - Hard and NP-Complete classes
• Cook’s theorem.
P and NP problems
• P problems refer to problems where an algorithm would take a
Polynomial time to solve.
• These are problems that would be considered ‘easy’ to solve.
• These problems can be solved in O(nk)time.
Example:
1.Linear search O(n)
2.Binary Search O(log n)
3.Merge sort O(nlogn)
P and NP problems
• NP problems refer to problems where an algorithm would take a
Non deterministic Polynomial time to solve.
• NP is a set of problems which can not be solved in a polynomial
time.
• For this class of problems, checking the solution would have a
polynomial run-time.
• P is s subset of NP Problems.
Example:
1.0/1knapsack problem O(2n)
2.Travelling sales person O(2n)
3.sum of subsets problem O(2n)
Design&analysisof Algorithms M.Raja Babu 4/29/23
Aditya Engineering College (A)
Cook’s theorem
• Cook’s Theorem states that SAT is NP-complete.
• Cook’s proved that Any NP problem can be converted to SAT in
polynomial time.
• Proof consists of two steps:
• If L is in NP hard Then it can be polynomial reduce to NP.
• If L is in NP complete then L blongs to NP
• If L is in NP then it can run by a NDTM with polynomial time.
So L can be run by a NDTM with Polynomial time.
So SAT is NP-Complete.
Design&analysisof Algorithms M.Raja Babu 4/29/23