0% found this document useful (0 votes)
109 views11 pages

Aditya Engineering College (A) : Unit-V

This document discusses NP-hard and NP-complete problems. It begins by explaining deterministic and non-deterministic algorithms, and that some algorithms like sorting have polynomial time complexity while problems like knapsack and traveling salesperson are exponential. It then defines P, NP, NP-hard and NP-complete problems, with NP problems having non-deterministic polynomial time and NP-hard problems not being solvable in polynomial time. Finally, it summarizes Cook's theorem which states that the satisfiability problem (SAT) is NP-complete.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views11 pages

Aditya Engineering College (A) : Unit-V

This document discusses NP-hard and NP-complete problems. It begins by explaining deterministic and non-deterministic algorithms, and that some algorithms like sorting have polynomial time complexity while problems like knapsack and traveling salesperson are exponential. It then defines P, NP, NP-hard and NP-complete problems, with NP problems having non-deterministic polynomial time and NP-hard problems not being solvable in polynomial time. Finally, it summarizes Cook's theorem which states that the satisfiability problem (SAT) is NP-complete.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

ADITYA ENGINEERING COLLEGE (A)

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.

Design&analysisof Algorithms M.Raja Babu 4/29/23


Aditya Engineering College (A)

• Some Algorithm we have seen like.


• ✓ Sorting - 𝑂(𝑁 log 𝑁)
• ✓ Binary Searching -𝑂(log 𝑁)
• ✓ Shortest Path Finding - 𝑂(𝑁2) polynomial time
• However, some algorithms
• 0/1knapsack problem-O(2n)
• Travelling sales person problem
• Sum Of subsets Exponential Time

Design&analysisof Algorithms M.Raja Babu 4/29/23


Aditya Engineering College (A)

Deterministic and non-deterministic algorithms


• Deterministic algorithms always provide a fixed predictable output for a given
particular input.
• Non-deterministic algorithms produce different outputs in different runs for the
same input.
• The non-deterministic algorithms use the following functions:
• 1. Choice: Arbitrarily chooses one of the element from given set.
• 2. Failure: Indicates an unsuccessful completion
• 3. Success: Indicates a successful completion

Design&analysisof Algorithms M.Raja Babu 4/29/23


Aditya Engineering College (A)

Deterministic and non-deterministic algorithms


• Deterministic algorithms have a polynomial running time but it is not polynomial
for non deterministic algorithms.
• We can write algorithms with exponential time as non deterministic with
polynomial time.

Design&analysisof Algorithms M.Raja Babu 4/29/23


Aditya Engineering College (A)

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)

Design&analysisof Algorithms M.Raja Babu 4/29/23


Aditya Engineering College (A)

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)

NP-Hard and NP-Complete 


• NP hard is a set of problems which can not be solved in a
polynomial time.
• A problem is NP hard if every problem in NP can be polynomial
reduced to it.
• NP complete is a set of problems which are NP and NP hard.
• NP-Complete problems are subclass of NP-Hard.
• All NP-Complete problems are NP-Hard but not all NP Hard problems
are not NP-Complete.
• NP complete are decision problems and NP hard are optimization
problems.
Design&analysisof Algorithms M.Raja Babu 4/29/23
Aditya Engineering College (A)

P, NP, NP-Hard and NP-Complete 

Design&analysisof Algorithms M.Raja Babu 4/29/23


Aditya Engineering College (A)

The satisfiability problem


• A formula φ is satisfiable if there exists an assignment of values to its
variables that makes φ true.
• The satisfiability problem, usually called SAT, is the following
language.
• SAT = {φ | φ is a satisfiable clausal formula}.
• Examples:
• P ^ Q is SAT for P=True Q=True

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

You might also like