Questions tagged [complexity-theory]

Questions related to the (computational) complexity of solving problems

Complexity theory classifies problems with respect to their computational hardness, i.e. which machine models can solve them under which restrictions, and the relations between these classes like the famous $\sf{P}$ and $\sf{NP}$ classes.

Computational complexity is about the inherent difficulty of computational problems, when some resource is limited and the impossibility of solving a problem within particular resource bounds (lower-bounds).

Time and space are the most common resource limits. These restrict the number of steps or tape squares that a Turing machine may use. Less common limits are the number of alternations, nondeterministic steps, bits of advice, or quantum bits used in the computation.

In the $\rm{P} \overset{?}{=} \rm{NP}$ question, time is polynomially bounded in the size of the input. This question asks whether polynomially many nondeterministic steps can decide some problem for which polynomially many deterministic steps is not enough.

The tag is more suitable when only very weak limits are placed on the allowed computations, for instance when the computation may use any finite amount of time.

For interactions that can continue indefinitely, consider instead the tags and . For questions asking for an algorithm to solve a particular problem, or upper-bounds on resources required to solve a problem, consider using .

5741 questions
336
votes
7 answers

What is the definition of P, NP, NP-complete and NP-hard?

I'm in a course about computing and complexity , and am unable to understand what these terms mean. All I know is that NP is a subset of NP-complete, which is a subset of NP-hard, but I have no idea what they actually mean. Wikipedia isn't much help…
130
votes
6 answers

Why hasn't there been an encryption algorithm that is based on the known NP-Hard problems?

Most of today's encryption, such as the RSA, relies on the integer factorization, which is not believed to be a NP-hard problem, but it belongs to BQP, which makes it vulnerable to quantum computers. I wonder, why has there not been an encryption…
Ken Li
  • 3,126
  • 4
  • 25
  • 38
110
votes
6 answers

How not to solve P=NP?

There are lots of attempts at proving either $\mathsf{P} = \mathsf{NP} $ or $\mathsf{P} \neq \mathsf{NP}$, and naturally many people think about the question, having ideas for proving either direction. I know that there are approaches that have been…
Raphael
  • 73,461
  • 31
  • 185
  • 415
87
votes
6 answers

How can we assume that basic operations on numbers take constant time?

Normally in algorithms we do not care about comparison, addition, or subtraction of numbers -- we assume they run in time $O(1)$. For example, we assume this when we say that comparison-based sorting is $O(n\log n)$, but when numbers are too big to…
70
votes
9 answers

What would be the real-world implications of a constructive $P=NP$ proof?

I have a high-level understanding of the $P=NP$ problem and I understand that if it were absolutely "proven" to be true with a provided solution, it would open the door for solving numerous problems within the realm of computer science. My question…
RLH
  • 879
  • 1
  • 8
  • 10
69
votes
3 answers

Knapsack problem -- NP-complete despite dynamic programming solution?

Knapsack problems are easily solved by dynamic programming. Dynamic programming runs in polynomial time; that is why we do it, right? I have read it is actually an NP-complete problem, though, which would mean that solving the problem in polynomial…
Strin
  • 1,555
  • 1
  • 11
  • 16
67
votes
2 answers

Are there subexponential-time algorithms for NP-complete problems?

Are there NP-complete problems which have proven subexponential-time algorithms? I am asking for the general case inputs, I am not talking about tractable special cases here. By sub-exponential, I mean an order of growth above polynomials, but less…
ksb
  • 801
  • 1
  • 7
  • 5
67
votes
7 answers

Is legislation NP-complete?

I would like to know if there has been any work relating legal code to complexity. In particular, suppose we have the decision problem "Given this law book and this particular set of circumstances, is the defendant guilty?" What complexity class…
64
votes
6 answers

If everyone believes P ≠ NP, why is everyone sceptical of proof attempts for P ≠ NP?

Many seem to believe that $P\ne NP$, but many also believe it to be very unlikely that this will ever be proven. Is there not some inconsistency to this? If you hold that such a proof is unlikely, then you should also believe that sound arguments…
pafnuti
  • 739
  • 1
  • 5
  • 7
64
votes
8 answers

Algorithmic intuition for logarithmic complexity

I believe I have a reasonable grasp of complexities like $\mathcal{O}(1)$ , $\Theta(n)$ and $\Theta(n^2)$ . In terms of a list, $\mathcal{O}(1)$ is a constant lookup, so it's just getting the head of the list. $\Theta(n)$ is where I'd walk the…
Khanzor
  • 1,491
  • 1
  • 13
  • 11
57
votes
4 answers

Why polynomial time is called "efficient"?

Why in computer science any complexity which is at most polynomial is considered efficient? For any practical application (a) , algorithms with complexity $n^{\log n}$ are way faster than algorithms that run in time, say, $n^{80}$, but the first is…
Ran G.
  • 20,964
  • 4
  • 63
  • 118
55
votes
3 answers

Why did Google not use an NP problem for their quantum supremacy experiment?

Reading discussions of the recent quantum supremacy experiment by Google I noticed that a lot of time and effort (in the experiment itself, but also in the excellent blog posts by Scott Aaronson and others explaining the results) is spent on…
Vincent
  • 761
  • 1
  • 5
  • 12
54
votes
6 answers

Why are some games np-complete?

I read the Wikipedia entry about " List of NP-complete problems " and found that games like super mario, pokemon, tetris or candy crush saga are np-complete. How can I imagine np-completeness of a game? Answers don't need to be too precise. I just…
racc44
  • 667
  • 2
  • 7
  • 11
51
votes
2 answers

What is the difference between an algorithm, a language and a problem?

It seems that on this site, people will often correct others for confusing "algorithms" and "problems." What are the difference between these? How do I know when I should be considering algorithms and considering problems? And how do these relate to…
48
votes
4 answers

What are common techniques for reducing problems to each other?

In computability and complexity theory (and maybe other fields), reductions are ubiquitous. There are many kinds, but the principle remains the same: show that one problem $L_1$ is at least as hard as some other problem $L_2$ by mapping instances…
1
2 3
…
99 100