SlideShare a Scribd company logo
P class
NP class
NP-Hard
NP-Complete
-By
Ziyauddin Shaik
CONCEPTS
 Problem
 Problem v/s Algorithm v/s Program
 Types of Problems
 Computational complexity
 P class v/s NP class Problems
 Polynomial time v/s Exponential time
 Deterministic v/s non-deterministic Algos
 Functions of non-deterministic Algorithms
 Non-deterministic searching Algorithm
 Non-deterministic sorting Algorithm
 NP - Hard and NP - Complete Problems
 Reduction & its properties
 Satisfiability problem and Algorithm
PROBLEM
“A computational problem specifies an input-output relationship.”
i.e. What does the input look like ?
What should the output be for each input ?
Example :
Input : A list of names of people
Output : The same list sorted alphabetically
Example:
Input : A picture in digital format
Output : A description of what the picture shows
Problem v/s Algorithm v/s Program
Aim - To convert centimeters to meters
PROBLEM ALGORITHM PROGRAM
we need to solve a An algorithm specifies A program is a computer executable
computational problem how to solve a problem description of an algorithm
Input : length in cm 1.Read cm #include<stdio.h>
Output : length in m 2.Calculate m=cm*0.01 #include<conio.h>
3.Print m void main()
{
float cm,m;
scanf(“%f”,&cm);
m=cm*0.01;
printf(“%f”,m);
getch();
}
Types of Problems
1. Tractable
2. Intractable
3. Decision
4. Optimization
1. Tractable Problems that can be solved in a
reasonable ( polynomial ) time
2. Intractable Problems that cannot be solved in a
reasonable time
3. Decision Problems that tries to answer a yes/no
question
4. Optimization Problems that tries to find an optimal
solution
Types of Problems
Computational complexity
“The amount of resources required to run an Algorithm”.
Depending on computational complexity of various problems,the problems can be
classified into 2 groups
computational complexity problems
P class NP class
NP complete NP hard
P class v/s NP class Problems
P class
The set of decision problems that
can be solved in polynomial time
using deterministic algorithms
are called P class problems
They can be solved and verified
in polynomial time
NP class
The set of decision problems that
can be solved in polynomial time
using non - deterministic algorithms
are called NP class problems
They can be verified in polynomial
time
NP
P
RULE :
Each space should be filled with
a digit of range (1-9) such that
It shouldn’t already present in
1 it’s row
2 it’s column
3 it’s block
Solving a Problem ( Sudoku )
It takes exponential time
RULE :
Each space should be filled with
a digit of range (1-9) such that
It shouldn’t already present in
1 it’s row
2 it’s column
3 it’s block
Verifying a Problem ( Sudoku )
It takes polynomial time
Polynomial time v/s Exponential time
Polynomial time
Linear search - n
Binary search - log n
Insertion sort - n2
Merge sort - n log n
Matrix multiplication - n3
Exponential time
0/1 knapsack - 2n
Travelling salesman - 2n
Graph colouring - 2n
Hamilton cycle - 2n
Sum of subsets - 2n
Time v/s input size (for polynomial & Exponential time Algorithms)
Deterministic v/s non-deterministic Algorithms
Deterministic
A Deterministic algorithm
produces only a single output
for the same input even on
different runs
1 0
0 0
Non-deterministic
A non - deterministic algorithm
can provide different outputs
for the same input on
different runs
q
q1
q2
q
q1
q2
Functions of non - deterministic algorithm
To specify such non - deterministic algorithms
we introduce three new functions
1. Choice(S) - arbitrarily chooses one of the elements of set S
2. Failure() - signals an unsuccessful completion
3. Success() - signals a successful completion
The assignment statement x=Choice(1,n) could result in x being
assigned any one of the integers in the range [1,n]
There is no rule specifying how this value is chosen
A non - deterministic searching algorithm
Searching for an element x in a given set of elements A[1:n], n>1. We are required
to determine an index j such that A[j]=x or j=0 if x is not in A.
Algorithm NSearch(A,n,key)
{
j=Choice(1,n);
if A[j]==key then
{
write( j);
Success( );
}
write ( 0);
Failure( );
}
Running Time : O(1)
Webinar : P, NP, NP-Hard , NP - Complete problems
NP - Hard and NP - Complete Problems
The NP class problems can be further categorized into
NP - hard and NP- complete problems
NP - Hard
A problem is NP - hard if all
other problems in NP can be
polynomially reduced to it
NP - Complete
A problem is NP - complete if it is
(a) in NP
(b) NP - hard
Relationship among P , NP , NP - hard , NP - complete problems
Problem
P
NP
NP - Complete
NP - Hard
Type
Tractable
Intractable
Decision
Optimization
Verifiable in
Polynomial time
YES
YES
YES
--
Solvable in
Polynomial time
YES
--
--
--
Complexity
Easy
Medium
Hard
Hardest
A B
Reduce
Webinar : P, NP, NP-Hard , NP - Complete problems
An expression that can
be constructed using
literals and operators
Either a
variable or it’s negation
whose value is either
TRUE or FALSE
A formula is said to
be satisfiable if
variables can be
assigned with values
such that the
formula turns out to
be TRUE
A formula is said to
be unsatisfiable if
variables cannot be
assigned with values
such that the
formula turns out to
be TRUE
Webinar : P, NP, NP-Hard , NP - Complete problems
Webinar : P, NP, NP-Hard , NP - Complete problems
THANK YOU

More Related Content

PPTX
Microsoft Power BI | Brief Introduction | PPT
PDF
Collaborating Using Cloud Services
PPT
Job Safety Analysis
PPTX
Number Systems
PDF
𝐆𝐞𝐧𝐞𝐫𝐚𝐭𝐢𝐯𝐞 𝐀𝐈: 𝐂𝐡𝐚𝐧𝐠𝐢𝐧𝐠 𝐇𝐨𝐰 𝐁𝐮𝐬𝐢𝐧𝐞𝐬𝐬 𝐈𝐧𝐧𝐨𝐯𝐚𝐭𝐞𝐬 𝐚𝐧𝐝 𝐎𝐩𝐞𝐫𝐚𝐭𝐞𝐬
PPTX
Ppt startup
PPT
Divide and conquer
PPTX
SMART CAR-PARKING SYSTEM USING IOT
Microsoft Power BI | Brief Introduction | PPT
Collaborating Using Cloud Services
Job Safety Analysis
Number Systems
𝐆𝐞𝐧𝐞𝐫𝐚𝐭𝐢𝐯𝐞 𝐀𝐈: 𝐂𝐡𝐚𝐧𝐠𝐢𝐧𝐠 𝐇𝐨𝐰 𝐁𝐮𝐬𝐢𝐧𝐞𝐬𝐬 𝐈𝐧𝐧𝐨𝐯𝐚𝐭𝐞𝐬 𝐚𝐧𝐝 𝐎𝐩𝐞𝐫𝐚𝐭𝐞𝐬
Ppt startup
Divide and conquer
SMART CAR-PARKING SYSTEM USING IOT

What's hot (20)

PDF
P, NP, NP-Complete, and NP-Hard
PPTX
Performance analysis(Time & Space Complexity)
PPT
Unit 1 chapter 1 Design and Analysis of Algorithms
DOC
Time and space complexity
PPT
Complexity of Algorithm
PDF
UNIT-V.pdf daa unit material 5 th unit ppt
PPTX
sum of subset problem using Backtracking
PDF
9. chapter 8 np hard and np complete problems
PPTX
Asymptotic Notations
PPTX
Asymptotic Notation
PDF
I.BEST FIRST SEARCH IN AI
PPTX
Divide and conquer - Quick sort
PPTX
Performance analysis and randamized agoritham
PPTX
Sum of subset problem.pptx
PPTX
Non- Deterministic Algorithms
PPTX
Constraint satisfaction problems (csp)
PPT
PDF
Time and Space Complexity
PPTX
Daa unit 1
PPT
Np cooks theorem
P, NP, NP-Complete, and NP-Hard
Performance analysis(Time & Space Complexity)
Unit 1 chapter 1 Design and Analysis of Algorithms
Time and space complexity
Complexity of Algorithm
UNIT-V.pdf daa unit material 5 th unit ppt
sum of subset problem using Backtracking
9. chapter 8 np hard and np complete problems
Asymptotic Notations
Asymptotic Notation
I.BEST FIRST SEARCH IN AI
Divide and conquer - Quick sort
Performance analysis and randamized agoritham
Sum of subset problem.pptx
Non- Deterministic Algorithms
Constraint satisfaction problems (csp)
Time and Space Complexity
Daa unit 1
Np cooks theorem
Ad

Similar to Webinar : P, NP, NP-Hard , NP - Complete problems (20)

PPTX
Lower bound theory Np hard & Np completeness
PDF
UNIT -IV DAA.pdf
PDF
Basic_concepts_NP_Hard_NP_Complete.pdf
PPTX
DAA_Hard_Problems_(4th_Sem).pptxxxxxxxxx
PPTX
AA ppt9107
PDF
Anlysis and design of algorithms part 1
PPT
Confidence interval two tail tests-lower bounds upperbounds
PPT
Np completeness h4
PPTX
Np Completeness
PPTX
Algorithm Design and Complexity - Course 6
PDF
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
PPT
Complexity theory
PDF
Lecture8
PPT
BCA Chapter 5 The Greedy Method Notes.ppt
PPT
class23.ppt
PPTX
lec2cct computational cmplexity theory.pptx
PPTX
UNIT-V.pptx-big data notes-ccs334anna university syllabus
PPTX
Complexity Classes.pptxfhasfuhaikfuahikhk
PDF
chapter1.pdf ......................................
PPTX
NP completeness
Lower bound theory Np hard & Np completeness
UNIT -IV DAA.pdf
Basic_concepts_NP_Hard_NP_Complete.pdf
DAA_Hard_Problems_(4th_Sem).pptxxxxxxxxx
AA ppt9107
Anlysis and design of algorithms part 1
Confidence interval two tail tests-lower bounds upperbounds
Np completeness h4
Np Completeness
Algorithm Design and Complexity - Course 6
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
Complexity theory
Lecture8
BCA Chapter 5 The Greedy Method Notes.ppt
class23.ppt
lec2cct computational cmplexity theory.pptx
UNIT-V.pptx-big data notes-ccs334anna university syllabus
Complexity Classes.pptxfhasfuhaikfuahikhk
chapter1.pdf ......................................
NP completeness
Ad

More from Ziyauddin Shaik (7)

PPTX
Operating Systems
PPTX
Introduction to python programming ( part-3 )
PPTX
Introduction to python programming ( part-2 )
PPTX
Introduction to python programming ( part-1)
PPTX
Product Design
PPTX
Capsule Endoscopy
PPTX
Amazon Go : The future of shopping
Operating Systems
Introduction to python programming ( part-3 )
Introduction to python programming ( part-2 )
Introduction to python programming ( part-1)
Product Design
Capsule Endoscopy
Amazon Go : The future of shopping

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
DOCX
573137875-Attendance-Management-System-original
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPT
Mechanical Engineering MATERIALS Selection
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
additive manufacturing of ss316l using mig welding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
CYBER-CRIMES AND SECURITY A guide to understanding
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Lesson 3_Tessellation.pptx finite Mathematics
573137875-Attendance-Management-System-original
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mechanical Engineering MATERIALS Selection
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing
OOP with Java - Java Introduction (Basics)
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Arduino robotics embedded978-1-4302-3184-4.pdf
Operating System & Kernel Study Guide-1 - converted.pdf
additive manufacturing of ss316l using mig welding

Webinar : P, NP, NP-Hard , NP - Complete problems

  • 2. CONCEPTS  Problem  Problem v/s Algorithm v/s Program  Types of Problems  Computational complexity  P class v/s NP class Problems  Polynomial time v/s Exponential time  Deterministic v/s non-deterministic Algos  Functions of non-deterministic Algorithms  Non-deterministic searching Algorithm  Non-deterministic sorting Algorithm  NP - Hard and NP - Complete Problems  Reduction & its properties  Satisfiability problem and Algorithm
  • 3. PROBLEM “A computational problem specifies an input-output relationship.” i.e. What does the input look like ? What should the output be for each input ? Example : Input : A list of names of people Output : The same list sorted alphabetically Example: Input : A picture in digital format Output : A description of what the picture shows
  • 4. Problem v/s Algorithm v/s Program Aim - To convert centimeters to meters PROBLEM ALGORITHM PROGRAM we need to solve a An algorithm specifies A program is a computer executable computational problem how to solve a problem description of an algorithm Input : length in cm 1.Read cm #include<stdio.h> Output : length in m 2.Calculate m=cm*0.01 #include<conio.h> 3.Print m void main() { float cm,m; scanf(“%f”,&cm); m=cm*0.01; printf(“%f”,m); getch(); }
  • 5. Types of Problems 1. Tractable 2. Intractable 3. Decision 4. Optimization
  • 6. 1. Tractable Problems that can be solved in a reasonable ( polynomial ) time 2. Intractable Problems that cannot be solved in a reasonable time 3. Decision Problems that tries to answer a yes/no question 4. Optimization Problems that tries to find an optimal solution Types of Problems
  • 7. Computational complexity “The amount of resources required to run an Algorithm”. Depending on computational complexity of various problems,the problems can be classified into 2 groups computational complexity problems P class NP class NP complete NP hard
  • 8. P class v/s NP class Problems P class The set of decision problems that can be solved in polynomial time using deterministic algorithms are called P class problems They can be solved and verified in polynomial time NP class The set of decision problems that can be solved in polynomial time using non - deterministic algorithms are called NP class problems They can be verified in polynomial time NP P
  • 9. RULE : Each space should be filled with a digit of range (1-9) such that It shouldn’t already present in 1 it’s row 2 it’s column 3 it’s block Solving a Problem ( Sudoku ) It takes exponential time
  • 10. RULE : Each space should be filled with a digit of range (1-9) such that It shouldn’t already present in 1 it’s row 2 it’s column 3 it’s block Verifying a Problem ( Sudoku ) It takes polynomial time
  • 11. Polynomial time v/s Exponential time Polynomial time Linear search - n Binary search - log n Insertion sort - n2 Merge sort - n log n Matrix multiplication - n3 Exponential time 0/1 knapsack - 2n Travelling salesman - 2n Graph colouring - 2n Hamilton cycle - 2n Sum of subsets - 2n
  • 12. Time v/s input size (for polynomial & Exponential time Algorithms)
  • 13. Deterministic v/s non-deterministic Algorithms Deterministic A Deterministic algorithm produces only a single output for the same input even on different runs 1 0 0 0 Non-deterministic A non - deterministic algorithm can provide different outputs for the same input on different runs q q1 q2 q q1 q2
  • 14. Functions of non - deterministic algorithm To specify such non - deterministic algorithms we introduce three new functions 1. Choice(S) - arbitrarily chooses one of the elements of set S 2. Failure() - signals an unsuccessful completion 3. Success() - signals a successful completion The assignment statement x=Choice(1,n) could result in x being assigned any one of the integers in the range [1,n] There is no rule specifying how this value is chosen
  • 15. A non - deterministic searching algorithm Searching for an element x in a given set of elements A[1:n], n>1. We are required to determine an index j such that A[j]=x or j=0 if x is not in A. Algorithm NSearch(A,n,key) { j=Choice(1,n); if A[j]==key then { write( j); Success( ); } write ( 0); Failure( ); } Running Time : O(1)
  • 17. NP - Hard and NP - Complete Problems The NP class problems can be further categorized into NP - hard and NP- complete problems NP - Hard A problem is NP - hard if all other problems in NP can be polynomially reduced to it NP - Complete A problem is NP - complete if it is (a) in NP (b) NP - hard
  • 18. Relationship among P , NP , NP - hard , NP - complete problems
  • 19. Problem P NP NP - Complete NP - Hard Type Tractable Intractable Decision Optimization Verifiable in Polynomial time YES YES YES -- Solvable in Polynomial time YES -- -- -- Complexity Easy Medium Hard Hardest
  • 22. An expression that can be constructed using literals and operators Either a variable or it’s negation whose value is either TRUE or FALSE A formula is said to be satisfiable if variables can be assigned with values such that the formula turns out to be TRUE A formula is said to be unsatisfiable if variables cannot be assigned with values such that the formula turns out to be TRUE