1

Ok, I really need help because I have read in so many books but still don't understand the complexity class NP.

These are the books:

  1. Theoretische Informatik; Katrin Erk, Lutz Priese (german)
  2. Grundkurs: Theoretische Informatik; Gottfried Vossen, Kurt-Ulrich Witt (german)
  3. Theoretische Informatik; Ingo Wegener (german)

Links:

  1. https://de.wikipedia.org/wiki/NP_(Komplexitätsklasse) (german)
  2. https://www.ibm.com/developerworks/community/blogs/jfp/entry/no_the_tsp_isn_t_np_complete?lang=en (english)

And I actually have more links but I can't post them here because I don't have enough reputation

So far I know:

  1. A problem L is in NP when there exists a nondeterministic algorithm which solves problem L in polynomial time.
  2. NP includes decision problems. If there exists a solution for these problems, it should be possible to check with a deterministic algorithm in polynomial time whether the solution is indeed a solution.

To 1.: is the calculated solution an exact match or is it just an approximation? To 2.: is it just necessary to be able to check in polynomial time? For example: the solution is not indeed a solution but I was able to check it in polynomial time. Is the problem still in NP?

For a problem to be in NP, I must have a nondeterministic algorithm which solves the problem in polynomial time. The solution is an exact match and I must be able to check in polynomial time with an deterministic algorithm that the solution is indeed a solution????????????????

Can someone please help me to understand.

Further thoughts: Let's take the TSP as an example. Question: Does a tour exist <= k ?

Let's assume I wrote a nondeterministic algorithm, which calculates a tour <= k. So my answer would be: Yes, a tour like that exists.

However Vladimir wrote in his answer: If this question can be answered by a polynomial time nondeterministic algorithm, then the language L is in NP.

So I gave an answer 'yes'; that means the TSP is in NP?! However what about if my answer would be: No, a tour like that does not exist! ? Then the TSP would not be in NP?

And looking on the other definition: Further I answered: Yes, a tour like that exists, because my nondeterministic algorithm calculated a tour like that. Now if I can check with a deterministic algorithm in polynomial time that the calculated tour is indeed verified to be correct, then TSP is in NP !?

Meliss
  • 31
  • 1
  • 3

2 Answers2

1

First of all note that a non-deterministic algorithm and a non-deterministic Turing machine are two different things.

A non-deterministic Turing machine is a computational model, while a non-deterministic algorithm "is an algorithm that, even for the same input, can exhibit different behaviors on different runs, as opposed to a deterministic algorithm" (Wikipedia). For example a QuickSort algorithm which partitions the array based on random choice of a pivot is a non-deterministic (probabilistic) algorithm.

So your definition 1 should be read as following

A problem $L$ is in $NP$ when there exists a nondeterministic Turing machine which solves problem $L$ in polynomial time.

Similarly, the second definition should be read as following:

NP includes decision problems. If there exists a solution for these problems, it should be possible to check on a deterministic Turing machine in polynomial time whether the solution is indeed a solution.

For the concept of $NP$ see this post.

fade2black
  • 9,905
  • 2
  • 26
  • 36
1

I think you have misunderstanding with the word 'solution'. It seems that you use it both for an answer to the decision problem and for a certificate that is used in the verification algorithm.

A decision problem is specified by a language $L$, and the problem can be formulated as a question: "Does $L$ contain an input word $w$?"

In the definition of $\operatorname{NP}$ via nondeterministic machines, we consider only this question. If this question can be answered by a polynomial time nondeterministic algorithm, then the language $L$ is in $\operatorname{NP}$.

In the definition that uses verification algorithm, the input to the verification algorithm is different. The (polynomial time) verification algorithm receives the word $w$ and a certificate $z$. If $w$ is contained in $L$, then it should have a certificate (of polynomially bounded length) that the verification algorithm accepts, and if $w$ is not contained in $L$, then there should be no such certificate.

The two definitions are equivalent, because it is possible to guess bits of the certificate using nondeterministic choice, and one can take a sequence of nondeterministic choices that leads to the positive answer as a certificate.

Update:

Consider the TSP problem: Given a weighted graph and a number $k$, does there exist a hamiltonian cycle of weight $\leq k$?

To prove that it is in $\operatorname{NP}$, we can present a poly-time nondeterministic algorithm, which decides this problem. That is, algorithm takes a graph and a number $k$, and if there is a tour of length $\leq k$ in the given graph, then our algorithm has at least one computational path where it answers "yes"; and if there are no short tours, then every path answers "no"

Or we can use a second definition, say that the tour, which we can encode as a sequence of vertices of the graph, is itself a poly-size certificate for its existence. Then we need to present a poly-time deterministic algorithm that takes a graph, a number $k$ and a sequence of vertices and checks if the given sequence defines a tour and the length of this tour is less than $k$.

Vladimir Lysikov
  • 435
  • 1
  • 3
  • 8