110 points · by olalonde · 16y ago · 73 comments
Fully polynomial approximation schemes.
Pseudo-polynomial time algorithms.
In other words, you may find that for all practical purposes this problem can be solved so fast that it doesn't really warrant the NP-badge in some sense. You can say that the problem is an NP problem which disguises itself as a P problem. It would be really fun to use David Pisingers knapsack algorithm codes, http://www.diku.dk/hjemmesider/ansatte/pisinger/codes.html and then bait the bidder into finding a set for which the algorithm is NOT fast (hint: That is also pretty hard :)
[1] Add some hand-waving about probability distributions here.
(Is there ever any other reason to generate multi-hundred digit numbers and try to factor them? Honest question, if anybody's got a fun answer, though I am asking about something actually useful that you know about, not something hypothetical.)
That is because factoring prime numbers is in the intersection between NP and co-NP. Co-NP is the set of problems where a "NO" answer is easily checkable with a certificate. If NP ?= co-NP is as much a question as P ?= NP. (I.e. no known proof either way, but every expects them to be unequal.)
This makes me think that the post could be a phish for programmers with strong maths comp-sci backgrounds, something Googlish?
Please someone try this!
Why is finding a set for which the algorithm does not work (edit:) WELL so hard? I have admittedly not read anything about -- or indeed, heard of -- KNAPSACK, but my impression was that we could estimate running time based on various measures of complexity of the problem. Is this incorrect, or is measuring the complexity of NP problems simply incredibly difficult?
The KNAPSACK problem is one of the "weak" NP problems in the sense that there is a pseudo-polynomial solution, see
http://en.wikipedia.org/wiki/Pseudo-polynomial_time
Intuitively, this means that KNAPSACK is still hard, but is easier than most other NP problems. Pisingers codes are so good that for most inputs the algorithm actually terminates quickly. There are still hard instances out there, but there are far between them. This means that a search for a hard instance might actually become rather cumbersome. Further, all realistic instances are probably realistically solvable so the instances we lack are more or less of theoretic interest.
So when you call NP-problems hard it is because it has been proven there are some nasty instances among them for which even the most clever NP-solver algorithm for the problem gives up and resorts to basically searching the whole solution space in exponential time.
Whatever the project, you get a bunch of replies (the majority from Indian) who either just say 'yes we can do that' or come back with boilerplate drivel without understanding the requirement.
The Indian guy who responded with a $300 bid and said: "I can do this for you in php or javascript. If you want this work in one language, I can charge less."
My bid was rejected and my account suspended for completing the work before my bid was accepted. I just hope those Clay guys see it so i can earn my $300.
Or am I being too gentle? It's hard to miss the title if you know what it means.
""" At the end of your post, write something like, “VERY IMPORTANT: To separate you from the spammers, please write I AM REAL as the first line of your bid. We will delete all bids that do not start with this phrase, since most bidders never read the requirements. Thank you for being one who does.” """
And with a background, you'd recognize hard problems?
Sure, very well-known NP-complete problems you'll recognize, but there are plenty of other problems that are equivalent to them, which you might stumble upon without even realizing it (I recently wrote a post about one such problem: http://www.loopycode.com/a-surprisingly-hard-problem-post-co...).
I worked on this, when I was bored in theoretical computer science classes.
Is that optional?
(Maybe I've been reading too specs that reference RFC2119.)
You can have an algorithm that uses exponential time and only polynomial space, but not the other way around.
Wouldn't this work? O(n * k)?
<?php
$input = array(-2, -3, 15, 14, 7, -10);
$sums = array();
foreach ($input as $val) {
$i = 0;
$count = count($sums);
foreach ($sums as $sum => $bool) {
if ($i >= ($count / 2)) {
break;
}
$sums[$sum + $val] = true;
}
$sums[$val] = true;
if (array_key_exists(0, $sums)) {
print "yes\n";
break;
}
}If he manages to prove that my submission doesn't solve his problem in polynomial time, I'll refund his money, but I'll also send his proof on to the Clay Institute.
Confuzzled!
The program should be able to work on any set given by the user.
the more numbers you add, the longer it takes to solve and p=np is that it should get all the answers instantly?
The more numbers there are, the longer it takes. If and only if P=NP, there is a solution which always finds the answer in polynomial time.