Questions tagged [np]

NP ("nondeterministic polynomial") is a complexity class of decision problems that can be solved by a nondeterministic Turing machine in polynomial time. Equivalently, it is the set of decision problems for which an answer can be verified in polynomial time by a deterministic Turing machine.

NP (nondeterministic polynomial-time) is a complexity class of decision problems that can be solved by a nondeterministic Turing machine in polynomial time. Equivalently, it is the set of decision problems for which an answer can be verified in polynomial time by a deterministic Turing machine.

For example:

  • 3-Colorability: Given a graph, can each vertex be colored red, green, or blue so that no two neighboring vertices have the same color?
  • Hamiltonian Cycle: Given a graph, is there a cycle that visits each vertex exactly once?
  • Traveling Salesperson: Given a set of n cities, and the distance between each pair of cities, is there a route that visits each city exactly once before returning to the starting city, and has length at most T?
  • Maximum Clique: Given a graph, are there k vertices all of which are neighbors of each other?
  • Subset Sum: Given a collection of integers, is there a subset of the integers that sums to exactly

References

492 questions
-1
votes
1 answer

Is it possible to write a program to print all pairs that add to k from an input array of size n

Is it possible to write a program to print all pairs that add to k from an input array of size n. If so how? I heard this problem is NP-Complete. I was wondering if we can provide a solution to this problem in typical programming languages like…
Mike
  • 19
-1
votes
1 answer

Prove that the reduction of HAM-CYCLE to TSP is polynomial-time?

This is a question that our professor uploaded yesterday, to prepare for our exam tomorrow. My problem with the question is part b (in boldface below); I'm not sure what I should do exactly. The Traveling Salesman Problem consists of a salesman and…
Faisal
  • 159
  • 9
-1
votes
2 answers

Np class of problems

Are All problems in NP are known to be reducible to one another. I know if a problem X is in NP and any NP problem Y in NP is reducible to X then X is NP-complete. So by this assumption can we state that all NP problems are reducible to one another?
-1
votes
1 answer

Why is the performance of the same loop algorithm differs

Right now I am doing assignments from cs 231 n , and I wanted to calculate euclidean distance between points: dists[i, j]=0 for k in range(3072): dists[i, j]+=math.pow((X[i,k] - self.X_train[j,k]),2) dists[i, j] = math.sqrt(dists[i,j]) however,…
Hype Totec
  • 31
  • 7
-1
votes
1 answer

In complexity class P, accepts=decides. Why not NP?

Suppose some problem L is in the complexity class P. Then there is some polynomial time algorithm A that decides the problem. We have the following theorem: if A accepts L, then A decides L. The proof works by noting that if A runs in polynomial…
-1
votes
1 answer

Why is A _< B always true in a Polynomial Reduction?

I'm extremely knew to Computer Science, particularly the theoretical side, so am trying to understand (without an answer going too far over my head) why is always true in a polynomial time reduction, and whether my naive theory as to why explains…
-1
votes
1 answer

Construct a ciruct from a graph that outputs 1 if the graph has an independent set

Let's say I have a graph, and from this graph I want to create a circuit K whose inputs can be set so that K outputs true iff the graph has an independent set of size ≥2. I've seen some decent stuff on the internet / youtube about how to go about…
David Dennis
  • 702
  • 2
  • 9
  • 26
-1
votes
1 answer

When will the residents of N (number of villages) meet again?

So, the problem is a part of a past programming competition paper I came across. Given a number N representing the number of villages around a city-center, the villagers of the first village go to the city every x1 to days to buy their supplies,…
dituoa
  • 65
  • 7
-1
votes
1 answer

Prove a language in not in coNP

Can someone tell me how to prove a particular problem/language does not belong to coNP? Intuitively, we should show that the complement of the problem is not in NP, but I am not sure this is the way to do this. Thanks.
Viorel
  • 1
  • 1
-1
votes
1 answer

NFA with half the strings in {0,1}^n

If there is an NFA M whose language L(M) is a subset of {0,1}* then how do you prove that determining if L(M) has fewer than half the strings in {0,1}^n for n>=0 is NP-hard.
-1
votes
1 answer

How to find the Big O for this algorithm, if it’s polynomial, P = NP

I would like to find if this algorithm is polynomial. It’s a solution to Partition Problem. As you might know, if is polynomial, P = NP. The algorithm is: ///// Partition Problem Algorithm var set = [3, 1, 1, 2, 2, 1]; var setCopy = set; var i =…
-1
votes
1 answer

NP complete or NP hard, in a equivalences problems?

I ran into a question. Finding of all cycle in a graph is NP-Complete. I see this note on Google search. counting all cycle in a graph is NP-Complete. are these two sentence equivalences ? can we say these two is NP-Hard? Thanks for every…
user4733521
-1
votes
2 answers

Algorithm for selecting subset of people who use same stuff NP-hard?

This isn't homework, but a question I encountered during my research. I need to know whether this problem is NP-hard or not. In the first case, I require an approximate algorithm and in the latter case an efficient one providing me with the optimal…
Chris
  • 721
  • 1
  • 10
  • 23
-2
votes
1 answer

How to estimate that this task is in class NP?

Here is my problem: Given numbers x1, ... xn. Numbers meet n files size and memory disk capacity D. We must understand, can we that files divided into 3 disks. The amount of file size recorded on any disc cannot exceed the disk capacity D. Let’s…
-2
votes
1 answer

What is the best algorithm for travelling sales man problem in case of there is few cites(lower than 6)?

i have seen many solution that try to solve the problem of travelling salesman problem if p!=np ,but i want to know the optimum solution if there is 6 or 5 cities only,which algorithm will give the optimum solution in this case?
1 2 3
32
33