P-NP-NP-Complete.doc

Share Embed Donate


Short Description

Download P-NP-NP-Complete.doc...

Description

P, NP, and NP-Complete Problems (due to: Anany Levitin) Definition 1 – We say an algorithm solves a problem in polynomial time if its worst case time efficiency belongs to O(p(n)) where p(n) is a polynomial of the problem’s input size n. Remember when we say O(x) we are giving an upper boun an clearly the function f(n) ! log"n is less than the function g(n) ! n#. $roblems that can be solve in polynomial time are sai to be tractable an those that cannot be solve in polynomial time are intractable.

% refresher from the beginning of the course in the following table n ' ' '* '*

log"n #.# . ' '#

n ' ' '* '*

1,

1!

1,

log n "n ##  '* '#* 1,!,

n" ' '* '** '**

"n ' '.#x'# 

n& #.x' +.#x'',

1,,,

Definition " / 0lass $ is a class of ecision problems that can be solve in polynomial time by (eterministic) algorithms. 1his class of problems is calle polynomial.

1his raises the 2uestion are all problems ecision problems3 4n fact the answer can be state as yes since we can convert the problem to a ecision problem that re2uires a yes5no answer. %s an example instea of as6ing what is the minimum number of colors neee to color a graph so that no two a7acent vertices have the same color can be restate as* oes there exist a graph with m colors for m ! '* "* #* 8(calle the m/ coloring problem). 9ow* we woner* can every ecision problem be solve in polynomial time3 1he answer unfortunately is no. 1here are even some problems that are 6nown to be undecidable. 1he most famous problem in this class is calle the #altin$ problem state by %lan 1uring in '+#. 1he halting problem as6s* given computer program $ an input set 4 oes the program halt. :ere is a simple an short proof of this fact. We will use contraiction an start by assuming that there exists algorithm % that solves the halting problem. 4n other wors for any program $ an input 4 we have; %($*4) !

'* if program $ halts in input 4< * if program $ oes not halt in input 4.

We can now consier program $ as an input to itself an use the output of algorithm % for pair ($*$) to construct the program = as follows; =($)! halts* if %($*$)!* i.e.* if program $ oes not halt in input $< oes not halt* if %($*$) ! '* i.e.* if program $ halts in input $.

1hen we substitute = for $ an get; =(=)! halts* if %(=*=)!* i.e.* if program = oes not halt on input =< oes not halt* if %(=*=)!'* i.e.* if program = halts on input =. 1his is a contraiction since neither of the two outcomes for program = is possible* an therefore completes the proof. 9ow* are there eciable but intractable problems3 1urns out the answer is yes* but luc6ily for us this is a very small set of 6nown problems. 1here are however many 6nown problems that o not have polynomial time algorithms (at least that we 6now of). 1he classic paper was publishe by >arey an ?ohnson in '+-+ an lists several hunre such problems. Definition % – % nondeterministic al$orit#mis a two/stage proceure that ta6es as input an instance 4 of a ecision problem an oes the following.

9oneterministic (guessing) stage; %n arbitrary string @ is generate that can be thought of as a caniate solution to the given instance 4. Aeterministic (verification) stage; % eterministic algorithm ta6es both 4 an @ as its input an outputs yes if @ represents a solution to instance 4. (4f @ is not a solution to instance 4* the algorithm either returns no or is allowe not to halt at all). We say that a noneterministic algorithm solves a ecision problem if an only if for every yes instance of the problem it returns yes in some execution. 4n other wors it guesses the answer an then verifies that the answer is correct. Binally we call the noneterministic algorithm nondeterministic polynomialif the time efficiency of the verification stage is polynomial. Definition & – 0lass 9$ is the class of ecision problems that can be solve by noneterministic polynomial algorithms. 1his class of problems is calle nondeterministic polynomial.

Cost ecision problems are in fact in 9$. Birst of all* this class inclues all the problems in $; P ⊆ NP.

1his is true since if a problem is in $* we can use a eterministic polynomial time algorithm that solves it in the verification stage of a noneterministic algorithm that simply ignores the string @ generate by the guessing stage. Of course the open 2uestion is oes;

$ ! 9$3 Definition ' – % ecision problem A ' is sai to be polynomially reducible to a ecision problem A" if there exists a function t that transforms instances of A ' to instances of A" such that

'. t maps all yes instances of A ' to yes instances of A " an all no instances in A' to no instances of A "< ". t is computable by a poly nomial time algorithm. 1his says that if A' is polynomially reucible to some problem A " that can be solve in polynomial time* the A' can also be solve in polynomial time. Definition  – % ecision problem A is sai to be NP-complete if

'. it belongs to the class 9$* an ". every problem in 9$ is polynomially reucible to A.

9ow assuming that we alreay 6now that the D1raveling @alesperson $roblemE to be 9$/ complete we will show that the D:amiltonian 0ircuit $roblemE also 9$/0omplete. ravelin$ *alesperson– Bin the shortest tour through n cities with 6nown positive integer istances between them. +amiltonian Circuit – Aetermine whether a given graph has a :amiltonian circuit (a path that starts an ens at the same vertex an passes through all the other vertices exactly once)

1o o this we nee to show that :amiltonian 0ircuit problem is polynomially reucible to the ecision version of 1raveling @alesperson. 1he latter can be state as the problem to etermine whether there exists a :amiltonian circuit in a given complete graph with positive integer weights whose length is not greater than a given positive integer m. We can map a graph > of a given instance of the :amiltonian circuit problem to a complete weighte graph >’ representing an instance of the traveling salesperson problem by assigning ' as the weight to each ege in > an aing an ege with weight " between any pair of non/a7acent vertices in >. %s an upper boun m in the :amiltonian circuit length* we ma6e m ! n* where n is the number of vertices in > (an >’). Obviously this transformation can be one in polynomial time. Fet > be a yes instance of the :amiltonian 0ircuit problem. 1hen > has a :amiltonian circuit* an its image >’ will have length n* ma6ing the image a yes instance of the ecision traveling salesperson problem. 0onversely* if we have a :amiltonian circuit of length not larger than n in >’* then its length must be exactly n (why3) an hence a circuit must be mae up of eges present in >* ma6ing the inverse image a yes instance of the traveling salesperson be a yes instance of the :amiltonian circuit problem. 1his completes the proof.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF