"Pseudo-polynomial-time"

Source: Internet
Author: User

Stack OverflowThere is a detailed explanation of the concept (pseudo-polynomial time).
Original Answer:
Algorithm-what is pseudopolynomial time? How does it differ from polynomial time?

I'm about to translate:
To understand "pseudo-polynomial time", we need to give a clear definition of "polynomial time" first.

For polynomial time, our intuitive concept is time complexity, which is a constant. For example, the time complexity of choosing a sort is a polynomial time, and the time complexity of solving the TSP problem is not polynomial time. We call this time complexity "traditional time complexity".

We generally believe that the variables in the traditional time complexity represent the input scale of the data. For example, select Sort, which refers to the number of elements in the array to be sorted, and the amount of nodes in the graph in the TSP problem. However, these so-called input sizes are simply intuitive definitions and not rigorous enough. To standardize these, we give a standard definition of the input scale when calculating the complexity of the standard time:
The input size of an issue is the number of bits required to hold the input data.

For example, if the input of the sorting algorithm is an array of 32-bit integers, then the input scale is the number of elements in the exponential group. For a graph with a node and an edge, the number of bits required is.

Understanding the definition of input scale, let's look at the standard definition of "polynomial time":
for one problem, if an algorithm can solve the problem in the O () time if the input size is x, then we call this algorithm polynomial time, which is a constant.

When we deal with issues such as graph theory, lists, arrays, and trees, the polynomial time under this standard definition is similar to our traditional polynomial time. For example, when sorting an array of elements with a selection sort, the traditional time complexity is. The input scale, therefore, gets the standard time complexity, which is still polynomial time.

Similarly, suppose to do Dfs (depth-first search) in a graph with nodes and edges, traditional time complexity is. Data size, so the standard time complexity is still polynomial time.

However, when we deal with some problems related to number theory, things are not very optimistic. Now let's talk about an algorithm that determines whether an integer is a prime number, and here's a simple algorithm:
function isPrime(n):    for i from 2 to n - 1:        if (n mod i) = 0, return false    return true
Obviously, this algorithm is polynomial time in the traditional time complexity calculation method. We may as well consider its traditional time complexity to be. Then we analyze the input scale of this problem, perhaps some students will say, for 32-bit integer, this input scale is not 32? This is true, but because in this case the input size is completely dependent on the size, so the range is no longer limited to the range of 32-bit integers, but rather to explore the impact on the size of the data when it is larger. We know that the number of bits required to save an integer, so that in the standard time complexity, the complexity of this algorithm becomes! This is no longer a polynomial time, but an exponential time.

We can intuitively feel the growth rate of this exponential time from the following example:
For a binary string:
10001010101011
We remember that the exponential time complexity algorithm runs at T.
Then, we're behind the binary string just add a bit
100010101010111
At this point, the algorithm runs to 2T (at least)! Therefore, just adding a few bits will make the algorithm run exponentially exponentially.

... ...

Finally, let's say pseudo-polynomial-timeDefinition of:
If the traditional time complexity of an algorithm is polynomial time, and the standard time complexity is not a polynomial time, then we call this algorithm pseudo polynomial time.

In addition, the original respondents also mentioned the pseudo-polynomial time algorithm in the application of encryption, polynomial time of the Prime judgment algorithm, interested students please go to the original answer.

"Pseudo-polynomial-time"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.