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
1 answer

Bin packing with item weight constraint

In the bin packing problem, we are given a set of items I={a1,...,an}, each item with weight w_a1,...,w_an, and a set of n bins with B={b1,..., bn} all bins with capacity C. I want to restrict the weights of the items to be polynomial in n. Is the…
Gabb
  • 11
  • 5
0
votes
0 answers

Get all possible simple paths between two nodes (Graph theory)

In the context of graph theory, I'm trying to get all the possible simple paths between two nodes. I record the network using an adjacency matrix stored in a pandas dataframe, in a way that network[x][y] store the value of the arrow which goes from…
Xbel
  • 735
  • 1
  • 10
  • 30
0
votes
1 answer

Is there an NP problem that is not NP-complete or P?

I am trying to understand the relationships between P, NP, NP-Complete and NP-Hard. I believe I am starting to understand the general idea but, I am hung up on this question(see title). What is an example of a problem that is not solvable in P…
0
votes
0 answers

Proving NP hard by polynomial reduction to 3SAT

I know the correct way of proving NP hard of a problem X is to reduce a known NP-Hard problem to X i.e. the direction is from the known, harder problem to the problem we want to prove is NP-Hard. But all NP-Complete problems are polynomially related…
ccying
  • 241
  • 1
  • 4
  • 15
0
votes
1 answer

Solving 3 non linear equations using fsolve

I want to find the valuews of a,b,c. It gives me error: from scipy.optimize import fsolve def equations(p): a,b,c = p return (a*np.log10([-b])+c, a*np.log10([100-b])+c-100, a*np.log10([80-b])+c-20) a,b,c = fsolve(equations, (1, 1,…
P.J
  • 197
  • 4
  • 15
0
votes
1 answer

Regex np++ Change different instances of "this" to different word

I have several of text files that contain the something like the following on many different lines: this_is_THIS.doc What I need to accomplish is to replace THIS with different objects for the first 5 occurrences and disregard the rest. I would…
Bobby Peters
  • 181
  • 1
  • 1
  • 9
0
votes
0 answers

Settling Debts -- Minimize all debts among people

I'm encountering a problem about Settling Debt that I can't fix. The problem is similar to Leetcode 465(Optimal Account Balancing). The input format is a list of transaction (like [[1, 3, 2], [1, 4, 3], [2, 4, 2]] and that means person 3 owes…
0
votes
2 answers

Prove that the problem of factoring α is in NP

Trying to brush up on computation theory but am not sure of solution to this: Prove that the problem of factoring α is in NP. I have a feeling it may be related to finding an NP problem and finding a reduction to the problem of factoring α.
Robben_Ford_Fan_boy
  • 8,494
  • 11
  • 64
  • 85
0
votes
1 answer

Calling a function that returns its updated output python

So I'm completely having a brain fart but I'm attempting to call a function that returns its own updated input in a for loop that has to run 30 times. I have the for loop part down I'm just not sure how to call the function correctly. def…
andrew fay
  • 95
  • 9
0
votes
1 answer

Possibilities of dividing a class in groups with several criteria

I have to divide a class of 50 students writing a dissertation in 10 different discussion groups of 5 members each. In theory, there are 1.35363x10^37 possible ways of doing this, which is just the result of {50!}/{(5!^10)*10!)}, if it is already…
AVT_DB
  • 1
  • 1
0
votes
1 answer

How to prove that the language $E_{tm}$ is $NP-Hard$

Consider the language $E_{tm}={ \langle M \rangle: M\text{is a Turing Machine that accepts nothing}$ I am not sure how to even start. My idea is to provide poly time reduction from some NP - Complete problem. E_tm What I don't understand is that,…
acagu
  • 23
  • 7
0
votes
1 answer

What is nondeterministic in NP exactly?

I am studying NP-Completeness and I have a question about the definition of the NP problems. Material says nondeterministic refers to the fact that a solution can be guessed out of polynomially many options in O(1) time Here, what does it mean…
invictus
  • 81
  • 5
0
votes
0 answers

Is this geometric cover NP-Complete and how can I prove it?

I have the following problem which I believe to be NP-Complete but I would like to prove it to be so: Given a set of M points on a plane where circles can be centered and a set of N points which need to be covered by the circles, find the minimum…
0
votes
1 answer

Polynomial Time algorithm to equate combination of right hand sum to left hand sum?

I have to write polynomial time algorithm for the problem which should say accept or reject if the number(s) to the left don't match to the number on right. You can group the numbers also, examples are below X & Y .......... & N = SUM where X,…
Arjun
  • 125
  • 1
  • 9
0
votes
2 answers

Packing rectangles in a rectilinear polygon

Given a set of axis-aligned rectangles (rotatable by 90 degrees) and a rectilinear polygon, I'd like to determine whether or not the rectangles can all be packed into this polygon, and if possible, find an arbitrary packing. Is this NP Hard? Would…
Rufus
  • 5,111
  • 4
  • 28
  • 45