SlideShare a Scribd company logo
1 of 4
NP-Completeness | Set 1 (Introduction)
We have beenwritingaboutefficientalgorithmstosolve complex problems,likeshortestpath,Euler
graph,minimumspanningtree,etc.Those were all successstoriesof algorithmdesigners.Inthispost,
failure storiesof computerscienceare discussed.
Can all computational problemsbe solvedbyacomputer?There are computational problemsthatcan
not be solvedbyalgorithmsevenwithunlimitedtime.ForexampleTuringHaltingproblem(Givena
program andan input,whetherthe programwill eventually haltwhenrunwiththatinput,orwill run
forever).AlanTuringprovedthatageneral algorithmtosolve the haltingproblemforall possible
program-inputpairscannotexist.A keypartof the proof is,Turingmachine wasusedas a mathematical
definitionof acomputerandprogram (Source HaltingProblem).
Statusof NPComplete problemsisanotherfailure story,NPcompleteproblemsare problemswhose
statusis unknown.Nopolynomial timealgorithmhasyetbeendiscoveredforanyNPcomplete problem,
nor has anybodyyetbeenable toprove thatno polynomial-timealgorithmexistsforanyof them.The
interestingpartis,if any one of the NPcomplete problemscanbe solvedinpolynomial time,thenall of
themcan be solved.
Attentionreader!Don’tstop learningnow.Getholdof all the importantDSA conceptswiththe DSA Self
PacedCourse at a student-friendlyprice andbecome industryready. Tocomplete yourpreparation
fromlearninga language toDS Algoandmany more, please referComplete InterviewPreparation
Course.
In case you wishtoattendlive classeswithexperts,please referDSA Live ClassesforWorking
ProfessionalsandCompetitive ProgrammingLive forStudents.
What are NP,P, NP-complete andNP-Hardproblems?
P isa setof problems thatcan be solvedbyadeterministicTuringmachine inPolynomial time.
NPis setof decisionproblemsthatcanbe solvedbya Non-deterministicTuringMachine inPolynomial
time.Pis subsetof NP(anyproblemthatcan be solvedbyadeterministicmachine inpolynomial time
can alsobe solvedbya non-deterministicmachine inpolynomial time).
Informally,NPisasetof decisionproblemsthatcanbe solvedbya polynomial-time viaa“Lucky
Algorithm”,amagical algorithmthatalwaysmakesa rightguessamongthe givensetof choices(Source
Ref 1).
NP-completeproblemsare the hardestproblemsinthe NPset. A decisionproblemLisNP-complete if:
1) L isin NP(AnygivensolutionforNP-complete problemscanbe verifiedquickly,butthere isno
efficientknownsolution).
2) EveryprobleminNPis reducible toLinpolynomial time (Reductionisdefinedbelow).
A problemisNP-Hardif itfollowsproperty2mentionedabove,doesn’tneedtofollowproperty1.
Therefore,the NP-Completesetisalsoasubsetof the NP-Hardset.
DecisionvsOptimizationProblems
NP-completenessappliestothe realmof decisionproblems. Itwasset upthis waybecause it’seasierto
compare the difficultyof decisionproblemsthanthatof optimizationproblems. Inreality,though,
beingable tosolve adecisionprobleminpolynomial time will oftenpermitustosolve the
correspondingoptimizationprobleminpolynomial time (usingapolynomial numberof callstothe
decisionproblem).So,discussingthe difficultyof decisionproblemsisoftenreallyequivalentto
discussingthe difficultyof optimizationproblems.(Source Ref 2).
For example,considerthe vertex coverproblem(Givenagraph,findoutthe minimumsizedvertexset
that coversall edges).Itisan optimizationproblem.Correspondingdecisionproblemis,given
undirectedgraphG andk, is there a vertex coverof size k?
What isReduction?
Let L1 andL2 be twodecisionproblems.Suppose algorithmA2solvesL2.That is,if y is an inputforL2
thenalgorithmA2will answerYesor NodependinguponwhetherybelongstoL2 or not.
The ideais to finda transformationfromL1to L2 so that algorithmA2can be part of an algorithmA1to
solve L1.
Learningreduction,ingeneral,isveryimportant.Forexample,if we have libraryfunctionstosolve
certainproblemsandif we can reduce a new problemtoone of the solvedproblems,we save alotof
time.Considerthe exampleof aproblemwhere we have tofindthe minimumproductpathina given
directedgraphwhere the productof path isthe multiplicationof weightsof edgesalongthe path.If we
have code for Dijkstra’salgorithmtofindthe shortestpath,we cantake the logof all weightsanduse
Dijkstra’salgorithmtofindthe minimumproductpathratherthanwritinga freshcode forthisnew
problem.
How to prove thata givenproblemisNPcomplete?
From the definitionof NP-complete,itappearsimpossible toprove thata problemLis NP-Complete. By
definition,itrequiresustothat showeveryprobleminNPinpolynomial timereducibletoL.
Fortunately,there isanalternate waytoprove it. The ideaisto take a knownNP-Complete problem
and reduce itto L. If polynomial timereductionispossible,we canprove that L isNP-Completeby
transitivityof reduction(If aNP-Complete problemisreducibletoL inpolynomial time,thenall
problemsare reducible toLinpolynomial time).
What was the firstproblemprovedasNP-Complete?
There mustbe some firstNP-Complete problemprovedbydefinitionof NP-Complete problems. SAT
(Booleansatisfiabilityproblem)isthe firstNP-Complete problemprovedbyCook(See CLRSbookfor
proof).
It isalwaysuseful toknowaboutNP-Completenessevenforengineers.Supposeyouare askedtowrite
an efficientalgorithmtosolve anextremelyimportantproblemforyourcompany.Afteralotof
thinking,youcanonlycome up exponential timeapproach whichisimpractical.If youdon’tknowabout
NP-Completeness,youcanonlysaythat I couldnot come withan efficientalgorithm.If youknow about
NP-Completenessandprove thatthe problemisNP-complete,youcanproudlysaythat the polynomial
time solutionisunlikelytoexist.If there isapolynomialtime solutionpossible,thenthatsolutionsolves
a big problemof computerscience manyscientistshave beentryingforyears.

More Related Content

What's hot

Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
Hitesh Wagle
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
Aakash deep Singhal
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 

What's hot (20)

MetiTarski's menagerie of cooperating systems
MetiTarski's menagerie of cooperating systemsMetiTarski's menagerie of cooperating systems
MetiTarski's menagerie of cooperating systems
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Algorithms : Introduction and Analysis
Algorithms : Introduction and AnalysisAlgorithms : Introduction and Analysis
Algorithms : Introduction and Analysis
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Ada notes
Ada notesAda notes
Ada notes
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
Algorithm Analyzing
Algorithm AnalyzingAlgorithm Analyzing
Algorithm Analyzing
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
01 Analysis of Algorithms: Introduction
01 Analysis of Algorithms: Introduction01 Analysis of Algorithms: Introduction
01 Analysis of Algorithms: Introduction
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
 
Analyzing algorithms
Analyzing algorithmsAnalyzing algorithms
Analyzing algorithms
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of Algorithms
 
CS8461 - Design and Analysis of Algorithms
CS8461 - Design and Analysis of AlgorithmsCS8461 - Design and Analysis of Algorithms
CS8461 - Design and Analysis of Algorithms
 

Similar to Np

Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysis
chidabdu
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theory
NYversity
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 

Similar to Np (20)

UNIT -IV DAA.pdf
UNIT  -IV DAA.pdfUNIT  -IV DAA.pdf
UNIT -IV DAA.pdf
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
 
Algorithm1
Algorithm1Algorithm1
Algorithm1
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysis
 
Toc
Toc Toc
Toc
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theory
 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculus
 
01-algo.ppt
01-algo.ppt01-algo.ppt
01-algo.ppt
 
Introduction
IntroductionIntroduction
Introduction
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Algorithms Design Patterns
Algorithms Design PatternsAlgorithms Design Patterns
Algorithms Design Patterns
 
Complexity Analysis
Complexity Analysis Complexity Analysis
Complexity Analysis
 
NP completeness
NP completenessNP completeness
NP completeness
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithms
 

Recently uploaded

Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
amitlee9823
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
AroojKhan71
 

Recently uploaded (20)

Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 

Np

  • 1. NP-Completeness | Set 1 (Introduction) We have beenwritingaboutefficientalgorithmstosolve complex problems,likeshortestpath,Euler graph,minimumspanningtree,etc.Those were all successstoriesof algorithmdesigners.Inthispost, failure storiesof computerscienceare discussed. Can all computational problemsbe solvedbyacomputer?There are computational problemsthatcan not be solvedbyalgorithmsevenwithunlimitedtime.ForexampleTuringHaltingproblem(Givena program andan input,whetherthe programwill eventually haltwhenrunwiththatinput,orwill run forever).AlanTuringprovedthatageneral algorithmtosolve the haltingproblemforall possible program-inputpairscannotexist.A keypartof the proof is,Turingmachine wasusedas a mathematical definitionof acomputerandprogram (Source HaltingProblem). Statusof NPComplete problemsisanotherfailure story,NPcompleteproblemsare problemswhose statusis unknown.Nopolynomial timealgorithmhasyetbeendiscoveredforanyNPcomplete problem, nor has anybodyyetbeenable toprove thatno polynomial-timealgorithmexistsforanyof them.The interestingpartis,if any one of the NPcomplete problemscanbe solvedinpolynomial time,thenall of themcan be solved. Attentionreader!Don’tstop learningnow.Getholdof all the importantDSA conceptswiththe DSA Self PacedCourse at a student-friendlyprice andbecome industryready. Tocomplete yourpreparation fromlearninga language toDS Algoandmany more, please referComplete InterviewPreparation Course. In case you wishtoattendlive classeswithexperts,please referDSA Live ClassesforWorking ProfessionalsandCompetitive ProgrammingLive forStudents. What are NP,P, NP-complete andNP-Hardproblems? P isa setof problems thatcan be solvedbyadeterministicTuringmachine inPolynomial time. NPis setof decisionproblemsthatcanbe solvedbya Non-deterministicTuringMachine inPolynomial time.Pis subsetof NP(anyproblemthatcan be solvedbyadeterministicmachine inpolynomial time can alsobe solvedbya non-deterministicmachine inpolynomial time). Informally,NPisasetof decisionproblemsthatcanbe solvedbya polynomial-time viaa“Lucky Algorithm”,amagical algorithmthatalwaysmakesa rightguessamongthe givensetof choices(Source Ref 1).
  • 2. NP-completeproblemsare the hardestproblemsinthe NPset. A decisionproblemLisNP-complete if: 1) L isin NP(AnygivensolutionforNP-complete problemscanbe verifiedquickly,butthere isno efficientknownsolution). 2) EveryprobleminNPis reducible toLinpolynomial time (Reductionisdefinedbelow). A problemisNP-Hardif itfollowsproperty2mentionedabove,doesn’tneedtofollowproperty1. Therefore,the NP-Completesetisalsoasubsetof the NP-Hardset. DecisionvsOptimizationProblems NP-completenessappliestothe realmof decisionproblems. Itwasset upthis waybecause it’seasierto compare the difficultyof decisionproblemsthanthatof optimizationproblems. Inreality,though, beingable tosolve adecisionprobleminpolynomial time will oftenpermitustosolve the correspondingoptimizationprobleminpolynomial time (usingapolynomial numberof callstothe decisionproblem).So,discussingthe difficultyof decisionproblemsisoftenreallyequivalentto discussingthe difficultyof optimizationproblems.(Source Ref 2). For example,considerthe vertex coverproblem(Givenagraph,findoutthe minimumsizedvertexset that coversall edges).Itisan optimizationproblem.Correspondingdecisionproblemis,given undirectedgraphG andk, is there a vertex coverof size k?
  • 3. What isReduction? Let L1 andL2 be twodecisionproblems.Suppose algorithmA2solvesL2.That is,if y is an inputforL2 thenalgorithmA2will answerYesor NodependinguponwhetherybelongstoL2 or not. The ideais to finda transformationfromL1to L2 so that algorithmA2can be part of an algorithmA1to solve L1. Learningreduction,ingeneral,isveryimportant.Forexample,if we have libraryfunctionstosolve certainproblemsandif we can reduce a new problemtoone of the solvedproblems,we save alotof time.Considerthe exampleof aproblemwhere we have tofindthe minimumproductpathina given directedgraphwhere the productof path isthe multiplicationof weightsof edgesalongthe path.If we have code for Dijkstra’salgorithmtofindthe shortestpath,we cantake the logof all weightsanduse Dijkstra’salgorithmtofindthe minimumproductpathratherthanwritinga freshcode forthisnew problem. How to prove thata givenproblemisNPcomplete? From the definitionof NP-complete,itappearsimpossible toprove thata problemLis NP-Complete. By definition,itrequiresustothat showeveryprobleminNPinpolynomial timereducibletoL. Fortunately,there isanalternate waytoprove it. The ideaisto take a knownNP-Complete problem and reduce itto L. If polynomial timereductionispossible,we canprove that L isNP-Completeby transitivityof reduction(If aNP-Complete problemisreducibletoL inpolynomial time,thenall problemsare reducible toLinpolynomial time). What was the firstproblemprovedasNP-Complete? There mustbe some firstNP-Complete problemprovedbydefinitionof NP-Complete problems. SAT (Booleansatisfiabilityproblem)isthe firstNP-Complete problemprovedbyCook(See CLRSbookfor proof). It isalwaysuseful toknowaboutNP-Completenessevenforengineers.Supposeyouare askedtowrite an efficientalgorithmtosolve anextremelyimportantproblemforyourcompany.Afteralotof
  • 4. thinking,youcanonlycome up exponential timeapproach whichisimpractical.If youdon’tknowabout NP-Completeness,youcanonlysaythat I couldnot come withan efficientalgorithm.If youknow about NP-Completenessandprove thatthe problemisNP-complete,youcanproudlysaythat the polynomial time solutionisunlikelytoexist.If there isapolynomialtime solutionpossible,thenthatsolutionsolves a big problemof computerscience manyscientistshave beentryingforyears.