4 ms·
Algorithm solves NP-Complete Problems in P time
- eesmith 7y ago> - each timestep, self-replicate the most recently made objects twice each, and append true, false to the array > - after N timesteps, every possible set of values for the boolean variables will be in memory Creating that takes O(2^N) time, hence this algorithm is not polynomial. It's especially not linear, as claimed.
- calhoun137 7y agoI disagree, did you run debugging tools to check how many frames this code takes to execute? On what basis are you claiming it takes O(2^N)? You just are just asserting that, but my code is running in time O(N) according to the debugger so im not sure why you are claiming that
- eesmith 7y ago"In computer science, big O notation is used to classify algorithms according to how their running time or space requirements grow as the input size grows" - https://en.wikipedia.org/wiki/Big_O_notation https://en.wikipedia.org/wiki/Big_O_notation It does not refer to the number of high-level execution frames, which appears to be what you measured. Consider that in Python: a = [] for i in range(500_000): a.append(i) a.reverse() takes about 0.1 seconds, while a = [] for i in range(500_000): a.insert(0, i) takes about a minute, to produce the same result. That's a factor of 600, even though the first one actually executes more Python code. This is because the first uses an amortized O(N) method, while the second uses an O(N^2) method. Hence, you need to measure run time, not the number of frames. I don't need to try it out because you wrote "every possible set of values for the boolean variables will be in memory", which requires O(2^N) values for the worst case, which require O(2^N) for the CPU to touch each memory cell. Also, try something with 10,000+ variables. Or one of the benchmark test sets from http://www.satcompetition.org/ http://www.satcompetition.org/ .
- calhoun137 7y agoThanks for this. After much research I have concluded that your reply here is accurate and my previous reply contained either misleading or wrong information. Your comments about space and high-level excution frames are on point imo. Thanks for taking the time to explain your thinking here, I really appreciate it! I only care about the execution time for my research purposes. See this Math SE post where I explain this algorithm as a people type algorithm system. Curious for your thoughts? ___ Imagine there is a party with an infinite number of mathematicians at it, and I walk up to my friend with the following instructions: "every 1 minute, find 1 person at the party who has not been told this message yet, and repeat this message to them" It's clear that after N minutes, provided these instructions are followed exactly, there will be 2^N people who have heard this message. I will now describe an algorithm which can solve the boolean satisfiability in N variables in N minutes. 1 - find 2 people at the party, hand one of them a paper that says "True" and another a paper which says "False" and has a boolean expression on it 2 - tell them these instructions "in 1 minute, find 2 people at the party who have not been told this message yet, and repeat this message to them, give 1 of these people your paper but add True to the list, find a new piece of paper and copy over the list + expression from the paper I gave you, but add False to the list" 3 - after N minutes, whoever has a piece of paper in their hands has to compute the solution of the boolean expression (we are assuming since all the people at the party are mathematicians, they can all check this in less than 30 seconds) and if its solvable they have to shout out "ITS SOLVABLE EVERYONE" Then given any boolean expression involving N variables, I can use this algorithm to solve the boolean satisfiability problem in N minutes and 30 seconds [1] https://math.stackexchange.com/q/3605352/1417 https://math.stackexchange.com/q/3605352/1417
- eesmith 7y ago"in 1 minute, find 2 people at the party who have not been told this message yet" What if they are not able to do so? Let's suppose the party has 1 million people, and you start in the center. At first it's easy to find 2 people. As the instructions spreads out, it gets harder and harder, because the number of new people you can reach within a minute goes from quadratic towards linear. "there will be 2^N people who have heard this message" Big-O complexity assumes an upper bound exists in the amount of compute power available. If the number of processors can grow exponentially to limitless size, then it's outside of the usual N vs. NP - many problems are linear if an unbounded amount of CPU power is available which can scale exponentially.