Class P, Class NP
Class P, Class NP
NP-Complete problem,
NP-Hard
• AMRUTHA R
• 1DB20CS011
THE CLASS 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
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