What is the difference between a polynomial and a pseudo-polynomial algorithm?
-
The difference between P and NP is clear. But the dynamic programming algorithm for knapsack is pseudo-polynomial. At the same time, knapsack is NP-complete. What's going on? What is an example of a problem that is NP but no pseudo-polynomial algorithm is known?
-
Answer:
Wikipedia's article on http://en.wikipedia.org/wiki/Pseudo-polynomial_time captures the idea perfectly: In http://en.wikipedia.org/wiki/Computational_complexity_theory, a numeric algorithm runs in pseudo-polynomial time if its http://en.wikipedia.org/wiki/Computation_time is http://en.wikipedia.org/wiki/Polynomial in the numeric value of the input (which is exponential in the length of the input â its number of digits).
Justin Rising at Quora Visit the source
Other answers
A polynomial time algorithm has running time polynomial in the length of the input. A pseudo-polynomial algorithm, on the other hand, takes time which is polynomial in the length of input if input written in unary form. As pointed out, this is same as polynomial in the numeric value of the input. Classic examples of pseudo-polynomial time algorithm include dynamic programming for Knapsack Problem and Bin Packing.
Anonymous
If [math]\Pi[/math] is a problem, and [math]I[/math] is an instance of the problem, then a polynomial algorithm solving [math]\Pi[/math] operates in time polynomial in the binary representation of [math]I[/math]. For example, suppose I wish to determine whether a given number [math]n[/math] exhibits a certain property. A polynomial algorithm solving the problem will run in [math]O(m^k)[/math] time for some [math]k[/math], where [math]m[/math] is the length of the binary representation of the input [math]n[/math] (in this case [math]m = \lfloor \log_2 n \rfloor + 1[/math]). A pseudo-polynomial algorithm solving a problem [math]\Pi[/math] operates in time polynomial in the unary representation (numerical value) of the input [math]I[/math]. In our example above, a pseudo-polynomial time algorithm will have running time [math]O(n^k)[/math], since [math]n[/math] is the length of the unary representation of [math]n[/math] ([math]\underbrace{111...1}_\textrm{n}[/math]). Now that we understand the definitions, the question is why do we care about algorithms that run in time polynomial in the numerical value of the input? Our computers represent data in binary! Well, it turns out the pseudo-polynomial time algorithms are very useful in constructing a PTAS (polynomial time approximation scheme) for certain ([math]NP[/math]-complete) problems. Why is that? 1. The numerical value of the input grows linearly with the input value, meaning that our metric for the size already grows pretty quickly â so that the extra steps algorithms may need to produce a solution does not "add much" to the already speedy increase of the metric. Therefore it is easier to find algorithms that operate in pseudo-polynomial time. 2. Once we come up with pseudo-polynomial time algorithms, we can use them to efficiently solve problems where the unary representation is guaranteed to be bounded by a polynomial in the binary representation. (For example, consider the Knapsack problem, but with the restriction that the profit associated with each item is bounded by a polynomial in the total number of items available. We can use a pseudo-polynomial time algorithm to solve this problem efficiently.) 3. In the cases where the no polynomial bound on the value exists (such as with general [math]NP[/math]-complete problems) we can translate an instance of a problem [math]I[/math] into a new instance [math]I'[/math] that is bounded in the desired way, suffering a modest and controlled error in the process (since we are in way ignoring some least significant bits of the input in order to compress it). This means that we can approximate, with a controlled error parameter, solutions to problems that we otherwise have yet to solve efficiently! That is exactly how, for example, we found algorithms finding solutions to the Knapsack problem that come arbitrarily close to the the optimal solutions, i.e. [math](1-\epsilon)OPT[/math], where the algorithms operates in time polynomial in both the size of the input and [math]1/\epsilon[/math]. Hooray!
Itai David Hass
Related Q & A:
- What is the difference between a chemtrail and a contrail?Best solution by Yahoo! Answers
- What is the difference between a countertenor and a sopranist?Best solution by Yahoo! Answers
- What is the difference between a Computer science (A.S.) and Computer Information Systems (A.S?Best solution by Yahoo! Answers
- What is the difference between a blog and a forum or a website?Best solution by Yahoo! Answers
- What is the difference between a for loop, a do while loop and a do loop?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.