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
0
votes
2 answers

Can it be proven no polynomial algorithm exists for an NP-Complete prob.?

I can't really seem to grasp what it really means to say a problem is NP-Complete. Could anyone help me with the following question? An NP-complete problem is a problem for which one can prove that an algorithm for solving it in polynomial time does…
StayPuff
  • 201
  • 1
  • 6
  • 13
0
votes
0 answers

Finding a Certain Length Cycle in a Undirected Graph - TSP

I have 80 nodes and I need to find a cycle of length 40 from these, while keeping the distance traveled by the cycle to a minimum. Some nodes cannot directly connect, they're in specific areas and I can only travel from one area to another, not…
rptynan
  • 190
  • 2
  • 3
  • 8
0
votes
1 answer

Variation of the job scheduling prob

I'm doing some administration work for an aviation transport company. They build aircraft containers and such here. One of the things they want me to code is a order optimization script that the guys on the floor can use to get the most out of the…
Clavus
  • 129
  • 1
  • 2
  • 12
-1
votes
1 answer

np.load from relative file in the python package

I have created a python package and I need to have np.load('./my_file.npy') in my package. when I install package and run the code the path is not correct and python cannot find the file I tried the following code as well dirname =…
WebMaster
  • 3,050
  • 4
  • 25
  • 77
-1
votes
1 answer

3 partition np completeness

I want to know how 3 partition problem is NP complete ? We have to find triplets in set which sums to target. So isn't time complexity will be O(n^3) which is polynomial ? solution:…
user
  • 25
  • 7
-1
votes
1 answer

I am unable to use np.concatenate

I have 2 variables from polynomial regression: y_test = [1.57325397 0.72686416] y_pred= [1.57325397 0.72686416] y_test is the y axis of the test i did, while y_pred is are the values i got from regressor.predict (regressor is the object of…
Newbie
  • 15
  • 3
-1
votes
1 answer

Filling index list with correct values

I have a list of index values. I want to match the index value to the correct information from an np array. How would I do this? example: index = [1, -2, -2, 0] #where -2 values are omitted, not present in array array = ['grape''purple''lizard',…
-1
votes
1 answer

Why is the NP-complete set restricted to only decision problems?

Among P, NP, NP hard and NP-complete, only the NP-complete set is restricted to decision problems (those that have a binary solution). What is the reason for this? Why not define it simply as the intersection of NP and NP-hard? And this leads to…
Rohit Pandey
  • 2,443
  • 7
  • 31
  • 54
-1
votes
2 answers

np.argsort not sorting correctly when value over a certain threshold

For some reason when I want to sort this matrix by the 3rd column with argsort, it does not work when element (3,3) in my matrix is greater than ten.. If its 9 or less it seems to sort correctly though. Does anyone know whats wrong here? X =…
ebhh
  • 1
  • 1
-1
votes
1 answer

proof of SAT np completeness

I know if we want to prove the np completeness of some problem we must show these : there is a nondeterministic polynomial solution for the problem all other np problems are reducible to the problem in the case of sat problem it's easy to show…
-1
votes
1 answer

polynomial time reduction from a problem to a NP-complete problem

I have problems to solve the following question: If there are two problems p1 and p2, p2 is NP-complete and there is a polynomial reduction from p1 to p2, then p1 ... a) is NP-hard but not necessarily NP-complete b) could be in P, even if P!=NP c)…
marc
  • 101
  • 2
-1
votes
1 answer

If X is NP-complete and Y is in NP, why Y must also be NP-complete

Suppose X and Y are decision problems for which X≤ P ​ Y, i.e., X is polynomial-time reducible to Y . If X is NP-complete and Y is in NP, why Y must also be NP-complete.
addy
  • 3
  • 2
-1
votes
1 answer

Iterating in a For Loop to check if previous value is greater than current value

pitch_per_ab = [] pitch_of_pa = pitcher['PitchofPA'] for i in range(len(pitch_of_pa)): prev_elem = pitch_of_pa[i-1] current_elem = pitch_of_pa[i] if current_elem <= prev_elem: np.append(pitch_per_ab, prev_elem) …
John Doe
  • 1
  • 3
-1
votes
1 answer

Classifying NP Completeness and Hardness

Choose the correct statement(s): (A) If X is an NP-complete problem, then X is an NP problem (B) If X is an NP-complete problem, then X is an NP-hard (C) Let X be an NP-complete problem. If X can polynomial reduce to a problem Y, then Y is an…
-1
votes
2 answers

Intuition behind why NP could be equals to co-NP , if we "assume" P not equals NP

if we "assume" P not equals NP , this and this suggests NP could be equals to co-NP . I searched a lot , and went through a lot of materials . I can't seem to quite intuitively understand why this could be true . It would be really helpful if…
Zarif
  • 445
  • 5
  • 12