Pseudo-polynomial time

Pseudo-polynomial time

In computational complexity theory, a numeric algorithm runs in pseudo-polynomial time if its running time is polynomial in the "numeric value" of the input (which is exponential in the "length" of the input -- its number of digits).

An Example

Consider the problem of testing whether a number "n" is prime, by naively checking whether no number in {2,3,..., "n"/2} divides "n" evenly. This approach can take up to "n"/2-1 divisions, which is indeed linear in "n" but not in the "size of n". For example, the number "n" = 2,000,000,000 would require approximately 1 billion divisions, even though the length of "n" is only 10 digits. Moreover one can easily write down an input (say, a 300-digit number) for which this algorithm is impractical. Since computational complexity measures difficulty with respect to the "length" of the (encoded) input, this naive algorithm is actually exponential. It "is", however, pseudo-polynomial time.

Contrast this algorithm with a true polynomial numeric algorithm -- say, the straightforward algorithm for addition: Adding two 9-digit numbers takes around 9 simple steps, and in general the algorithm is truly linear in the length of the input. Compared with the actual numbers being added (in the billions), the algorithm could be called "pseudo-logarithmic time", though such a term is not standard. Thus, adding 300-digit numbers is not impractical. Similarly, long division is quadratic: an "m"-digit number can be divided by a "n"-digit number in O(mn) steps (see Big O notation.)

In the case of primality, it turns out there is a different algorithm for testing whether "n" is prime (discovered in 2002) which runs in time O(log^6{n}).

Ramifications

If a problem is in P, then it perforce has a pseudo-polynomial time algorithm. But NP-Complete problems may also have pseudo-polynomial time algorithms (for example, the Knapsack problem).Garey and Johnson write:

A pseudo-polynomial-time algorithm … will display 'exponential behavior' only when confronted with instances containing 'exponentially large' numbers, [which] might be rare for the application we are interested in. If so, this type of algorithm might serve our purposes almost as well as a polynomial time algorithm.
(where by "exponentially large numbers", they mean "numbers with many digits").On the other hand, some NP-complete problems remain NP-complete even when their numeric parameters are polynomially bounded in their size. Such problems are called Strongly NP-complete.

Generalizing to non-numeric problems

Although the notion of pseudo-polynomial time is used almost exclusively for numeric problems, the concept can be generalized:The function "m" is pseudo-polynomial if"m"("n") is no greater than a polynomial function of the problem size "n" and an additional property of the input, "k"("n"). (Presumably, "k" is chosen to be something relevant to the problem.)This makes numeric problems a special case by taking "k" to be the number of (binary) digits of the input.

The distinction between the value of a number and its length is one of encoding: if numeric inputs are always encoded in unary, then "pseudo-polynomial" would coincide with "polynomial".

References

* M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman and Company, 1979.


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Time complexity — In computer science, the time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the size of the input to the problem. The time complexity of an algorithm is commonly expressed using big O… …   Wikipedia

  • Knapsack problem — BKP redirects here. For other uses, see BKP (disambiguation). Example of a one dimensional (constraint) knapsack problem: which boxes should be chosen to maximize the amount of money while still keeping the overall weight under or equal to… …   Wikipedia

  • Subset sum problem — In computer science, the subset sum problem is an important problem in complexity theory and cryptography. The problem is this: given a set of integers, does the sum of some non empty subset equal exactly zero? For example, given the set { −7, −3 …   Wikipedia

  • Weakly NP-complete — In computational complexity, an NP complete (or NP hard) problem is weakly NP complete (or weakly NP hard), if there is an algorithm for the problem whose running time is polynomial in the dimension of the problem and the magnitudes of the data… …   Wikipedia

  • Partition problem — In computer science, the partition problem is an NP complete problem. The problem is to decide whether a given multiset of integers can be partitioned into two halves that have the same sum. More precisely, given a multiset S of integers, is… …   Wikipedia

  • List of mathematics articles (P) — NOTOC P P = NP problem P adic analysis P adic number P adic order P compact group P group P² irreducible P Laplacian P matrix P rep P value P vector P y method Pacific Journal of Mathematics Package merge algorithm Packed storage matrix Packing… …   Wikipedia

  • Randomized algorithm — Part of a series on Probabilistic data structures Bloom filter · Skip list …   Wikipedia

  • Linear programming — (LP, or linear optimization) is a mathematical method for determining a way to achieve the best outcome (such as maximum profit or lowest cost) in a given mathematical model for some list of requirements represented as linear relationships.… …   Wikipedia

  • 2-satisfiability — In computer science, 2 satisfiability (abbreviated as 2 SAT or just 2SAT) is the problem of determining whether a collection of two valued (Boolean or binary) variables with constraints on pairs of variables can be assigned values satisfying all… …   Wikipedia

  • One-way function — Unsolved problems in computer science Do one way functions exist? In computer science, a one way function is a function that is easy to compute on every input, but hard to invert given the image of a random input. Here easy and hard are to be… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”