Академический Документы
Профессиональный Документы
Культура Документы
NP Completeness
Complexity Classes
Veningston. K
Computer Science and Engineering
Unit V - Outline
– Terminologies
– Examples
– Complexity Class - P, NP, NP-Complete, NP-Hard
– Is P=NP?
– Reducibility
•Design and Analysis of Algorithms
•2
(18CSE107)
Introduction to NP Completeness
Decidable Problems
Undecidable Problems
No algorithm
exists. Example:
Tractable Intractable
Halting Problem of
If there exist If the Turing Machine
at least one problem is
polynomial not tractable, ✘
bound then it is
algorithm intractable
O(nk) O(cn),
O(nlogn)
Problem Classification
• 2 types:
– Decidable problem
– Undecidable problem
• If there exist an algorithm to solve a problem,
then it is called decidable problem
• If there exist no algorithm, then it is called
Undecidable problem
What is algorithm?
• It is a procedure which supposed to halt after some
time.
• If we do not have any algorithm which halts, then
there is no algorithm
Polynomial Time Complexity Exponential Time Complexity
Linear Search - O(n) 0/1 Knapsack - O(2n)
Binary Search -O(log n) TSP - O(n22n)
Merge sort - O(n log n) Sum of subsets - O(2n)
Quick sort - O(n log n) Hamiltonian cycle - O(n22n)
Insertion sort - O(n2) Satisfiability - O(2n)
Matrix multiplication - O(n3) Clique in graph - O(2n)
Types of problems
• 2 Types
– Tractable
– Intractable
• Tractable
– Fast algorithm
– Easy problems are called tractable problems
– There exists at least one polynomial bound algorithm O(nk)
• Intractable
– Problems which are not tractable, then it is intractable
– Exponential time algorithm If we do not find any
algorithm which runs in polynomial time O(cn)
Tractable vs. Intractable
Problems solvable
in polynomial time.
NP Problems
Problems solvable
in polynomial time.
P Problems NP Problems
P vs. NP
• P
– If the problem is solvable in polynomial time, it is P
• NP
– If the problem is decidable and if we do not have any
polynomial time algorithm till now, then these problems
are NP
– We do not know anything about NP
• We do not whether they could be solved in polynomial time or
they cannot be solved in polynomial time
• Future will decide (No one knows)