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

DAA Unit-V Material

Unit 5 discusses P, NP, NP-Hard, and NP-Complete problems, defining P-Class problems as those solvable in polynomial time and NP-Class problems as those verifiable in polynomial time but not necessarily solvable in it. NP-Hard problems can be polynomially reduced from NP problems, while NP-Complete problems are both in NP and NP-Hard. The document also covers non-deterministic and deterministic algorithms, reduction methods, and introduces concepts like satisfiability and Cook's Theorem.

Uploaded by

Sai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
2 views

DAA Unit-V Material

Unit 5 discusses P, NP, NP-Hard, and NP-Complete problems, defining P-Class problems as those solvable in polynomial time and NP-Class problems as those verifiable in polynomial time but not necessarily solvable in it. NP-Hard problems can be polynomially reduced from NP problems, while NP-Complete problems are both in NP and NP-Hard. The document also covers non-deterministic and deterministic algorithms, reduction methods, and introduces concepts like satisfiability and Cook's Theorem.

Uploaded by

Sai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
Unit—5 : P, NP, NP Hard and NP Complete Problems Unit - 5: P, NP, NP Hard and NP Complete Problems Basically, any problem can be given, we have to write an algorithm to solve it. ‘The algorithm that we have to write in cither polynomial time or non-polynomial time. P-Class problems A problem which can be solved in polynomial time is known as P-Class problems, P= { problems solvable in polynomial time } Size of the problem = on Polynomial time = =~ ® time Eg: All sorting and searching algorithms can be solved in polynomial. time! NP-Class problems A problem which cannot be solved in polynonnial tine, but is verified ingpalyrdDrial time is knows as Non-Polynomial or NP Class problems NP = { Decision problems solvable in non-deterfainistie;polynomial time } Decision = Yes / No Non-Deterministic : Guess one of the polynomially*many/ operations. If any guess would lead to YES answer then we get such as guess. Eg: Su-Du-Ku, prime factor, scheduling problms Travelling salesmen problem, etc ‘The NP-Class problems, it is verified polys@inial time and can have the following features: © Hard w solve ©: Easyto-vetily * Taking exponential tishe taisolve © Taking polynomial timeyto verify NP Class The P-Class problems can bva¥e tie following features: © Easy to solve © Easy to vefily PCNP Example: non detetipinistic algorithms and choice, failure and success functions with search example Algorithm NSearch (A, n, key) { j = choice(); if key == Aj then write (3); success () ; © Taking Bolypomial time to solve and verily t write (3); failure (); Design and Analysis of Algorithms (R2031052) Page | 36 Unit—5 : P, NP, NP Hard and NP Complete Problems Non-Deterministic algorithms Output cannot be predicted properly even we know the input of the problem. NP problems can be give different output for different rounds of execution of the same input. © For same input, ie. 0, the non-deterministic algorithths jf be generated different outputs as ourpute —> Qi and output» > Qe 0 (2°) Hence, we have ambiguity to produce proper outputs Algorithms will take mote than one path; hence we eqgnt determine next step Q) of te execution, > # Accurate solutions cannot be provided. Only afipoximate solution shall be (22) provided by non-dererministic algorithms Such kind of algorithms are known as HOnsdet@#ninistic algorithms Eg: Manto-Carlo problems, Genetic algorithms, ete. Deterministic Algorithms 0 (2) — + Ourputs are different for different inputs, ic, for 0, the deterministic o) algorithms can be generatcd®@ufput as outputo > Qi and for 1, the deterministic algorithms tag be geferated output as output, > Qe 7 @ © Hence, there should ngtibe Any ambiguity in generation of outputs. © Such kind of algorithms ireKiown as deterministic algorithms Reduction Consider, we have two problems ofideeton Yype as P; and P:. Outputs of these problems ean be either YES or NO. Consider the following.scenifio of these two problems as _— Input (11) _—_ Input (13) Py P, ™ Algoithm (8) ™ Algorithm (Aa) Unknown ‘Known If Problem-1 cainhe sdlyed with the help of Algorithm-2, then we convert input Input-l into Input-2 and find the solution #8r Problem-2 hene: ., we can consider Problem-1 is reduced to Problem-2. Input-1 Fun(l) =I Algorithm-2 >Output-2 Identify a, Function Fun() which takes Input; as parameter and converts into Inputs, hence using Algoxitht. we shall get the output as Outputs. Therefore, P: is reducible to P: Design and Analysis of Algorithms (R2031052) Page | 37 Unit—5 : P, NP, NP Hard and NP Complete Problems NP-Hard A problem is NP Hard, if every problem in NP can be polynomially reduced. NP-Complete A problem is called NP-Complete if the problem P is in NP and the problem P is in NP-Hard, NP.Complete Satisfiability (SAT) Given Boolean function F? and a interpretation ‘M’ which maps ataziable to True / False can be called satisfiability. When we evaluate F under M to produce a Booleanegesulé by following: © Base case is ‘True: which returns True © Base case is False: which returns False @ Base case is a variable ‘var’: which retuggs®war" iit © Inductive cases: returns result by using teuth\tables. SAT solves 1 automatically finds a satisfying the,givemintérpretation. In SAT, the Boolean function can be represented in Conjunctive Normal Form(GNE) 48: Formula is a conjunction of clauses. Clause {s ®disjunction of literals. Literal is a variable or its negation. A formula is to be true, if and only ifteacl? elatise must be in SAT. In each clause some literals must be TRUE. The CNF satisfiability probleimis‘a.vetSion of satistiability problem where Boolean formula is specified in the Conjunctive Normal Form meas that is a conjunction of clauses, where a clauses where a clause is a disjunction of literals and afiveral is a variable or its negation, 3-SAT A language is in 3-SA{ iP %pid only if the language must be satisfiable 3 CNP formula. 3SAT = { © | Gis satisfiable 3 CNF formula } Cook’s Theorem Definition; Lhe'problem of determining, whether a Boolean expression is satisHiable in NP complete, ie., satisfiabilifyiproblem is in NP-Complete if and only if P = NP. Proof, 4g) Lis a language in NP. 2. Any language L' in NP reducible to L. 3. Define a non-deterministic Turing machine which non-deterministically guess value for each of the variable in language L! will be reduced in polynomial time to L. 4, Hence, Lis polynomially reducible to L, therefore, P = NP. Design and Analysis of Algorithms (R2031052) Page | 38

You might also like