Question 1136 in The Design and Analysis of Algorithms Third
Question 11.3.6 in The Design and Analysis of Algorithms, Third Edition
Consider the following brute-force algorithm for solving the composite number problem: Check successive integers from 2 to [n/2] as possible divisors of n. If one of them divides n evenly, return yes (i.e., the number is composite); if none of them does, return no. Why does this algorithm not put the problem in class P?
Solution
P is the class of choice problems for which we can get an answer in polynomial moment. Definition a polynomial time function is now functions that can be calculate in a time polynomial in the amount of its parameter. Meaning P is the class of decision problems L such to there is a polynomial time function f wherever x is a string and f=True if and simply if x is in L.
NP is the class of decision troubles for which we can verify solution in polynomial time. meaning NP is the class of decision problems L such that there is a polynomial time function f(x, c) there x is a string, c is a different string whose size is polynomial in the size of x, and f(x, c) =True if and simply if x is in L. c in the meaning is called a certificate, the further information wanted to show that x is certainly in the language. NP stand for nondeterministic polynomial time, from an rotate, but comparable, definition connecting nondeterministic Turing equipment that are allowed to estimate a certificate and then verify it in polynomial time.
Note: A regular error when talking of P and NP is to misremember that NP stands for non polynomial avoid this trap, except you want to verify it an model of a decision problem in NP is: Decision Problem. Complex Number request. Binary programming of a +ve integer n. Language. All instance for which n is multiple, i.e., not a major number. We can look at this as a language L by cleanly coding n in log n bits as a binary number, so each binary combination number is in L, and nobody else. We can show this trouble is in NP by provide a polynomial time f(x,c) also identified as a polynomial time proof system for L. In this case, c can be the binary encoding of a non trivial issue of n. as c can be no better than n, the range of c is polynomial in the size of n. The function f simply check to see whether c divide n evenly; if it does, then n is prove to be combined and f return
