0% found this document useful (0 votes)
113 views

Class P, Class NP

Class P contains problems that can be solved in polynomial time by a deterministic algorithm. Examples include fractional knapsack and minimum spanning tree. Class NP contains problems that can be verified in polynomial time by a non-deterministic algorithm, even if they may not be solvable in polynomial time deterministically. Examples include travelling salesman and satisfiability. P is a subset of NP. NP-hard problems are at least as hard as any problem in NP, meaning problems in NP can be reduced to NP-hard problems in polynomial time. NP-complete problems are NP and NP-hard - they are the hardest problems in NP.

Uploaded by

Amrutha R
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)
113 views

Class P, Class NP

Class P contains problems that can be solved in polynomial time by a deterministic algorithm. Examples include fractional knapsack and minimum spanning tree. Class NP contains problems that can be verified in polynomial time by a non-deterministic algorithm, even if they may not be solvable in polynomial time deterministically. Examples include travelling salesman and satisfiability. P is a subset of NP. NP-hard problems are at least as hard as any problem in NP, meaning problems in NP can be reduced to NP-hard problems in polynomial time. NP-complete problems are NP and NP-hard - they are the hardest problems in NP.

Uploaded by

Amrutha R
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/ 10

Class P, Class NP ,

NP-Complete problem,
NP-Hard
• AMRUTHA R
• 1DB20CS011
THE CLASS P

 P: The class of problems that have polynomial-time deterministic algorithms.


 That is, they are solvable in O(p(n)), where p(n) is a polynomial on n
 A deterministic algorithm is(essentially) one that always computes the correct answer
Sample Problems in P

 Fractional Knapsack
 Mst
 Sorting
THE CLASS NP

 NP: The class of decision problems that are solvable in polynomial time on a
nondeterministic machine (or with a nondeterministic algorithm)
A deterministic computer is what we know
A nondeterministic computer is one that can “guess” the right answer or solution
 Think of a nondeterministic computer as a parallel machine that can freely spawn an
infinite number of processes
 Thus NP can also be thought of as the class of problems “whose solutions can be verified
in polynomial time”
 Note that NP stands for “Nondeterministic Polynomial-time”
Sample Problems in NP

 Fractional Knapsack
 MST
 Travelling Salesman
 Graph Coloring
 Satisfiability(SAT)
P and NP Summary

 P=Set of problems that can be solved in polynomial time


Examples: Fractional Knapsack.
 NP = Set of problems for which a solution can be verified in polynomial time
Examples: Fractional Knapsack, TSP.
 Clearly P is subset of NP
 P ≠ NP
NP-Hard

 A lot of times you can solve a problem by reducing it to a different problem. I can reduce
Problem B to Problem A if, given a solution to Problem A, I can easily construct a
solution to Problem B. (In this case, "easily" means "in polynomial time.“).
A problem is NP-hard if all problems in NP are polynomial time reducible to it.
Example : Hamiltonian Cycle
Every problem in NP is reducible to Hamiltonian Cycle in polynomial time . That is TSP is
reducible to HC.
NP-COMPLETE PROBLEMS

 A Problem is NP – Complete if the problem is


both
 NP-Hard and
 NP
P , NP, NP – Complete , NP - Hard

You might also like