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

np.genfromtxt error in python 3

When I use dataset = np.genfromtxt(open('data/train.csv','r'), delimiter=',', dtype='f8,str')[1:] I obtain this error TypeError: must be str or None, not bytes Could you help me to find the solution?
Nacho
  • 35
  • 5
3
votes
1 answer

Is it Polynomial time algorithm

If an algorithm's input size is 2^n and the algorithm runs in $O(n2^n)$ time. In this case, can we say that the algorithm runs in polynomial time with respect to input size?
NARAYAN CHANGDER
  • 319
  • 4
  • 13
3
votes
1 answer

What are NP-Intermediate problems?

Assuming P != NP The euler diagram shows a part not part of P and NP-complete. I read on wikipedia that this set is called NP-Intermediate. Euler Diagram I have some doubts as to how are NPI problems defined?
Sam Radhakrishnan
  • 681
  • 1
  • 5
  • 19
3
votes
3 answers

Non deterministic Polynomial(NP) vs Polynomial(P)?

I am actually looking for description what NP alogrithm actually means and what kind of algo/problem can be classified as NP problem I have read many resources on net . I liked https://www.quora.com/What-are-P-NP-NP-complete-and-NP-hard What are…
emilly
  • 10,060
  • 33
  • 97
  • 172
3
votes
1 answer

Algorithm to determine best combinations - Bin Packing

Given a set of items, each with a value, determine the number of each item to include in a collection so that the total value is less than or equal to given limit and the total value is as large as possible. Example: Product A = 4 Product B =…
user444651
  • 39
  • 2
  • 4
3
votes
1 answer

How exactly does a Max 2 Sat reduce to a 3 Sat?

I've been reading this article which tries and explains how the max 2 sat problem is essentially a 3-sat problem and is NP-hard. However, if you see the article, I'm not able to understand why, after ci is satisfied, 7 out of 10 clauses are…
gabbar0x
  • 4,046
  • 5
  • 31
  • 51
3
votes
2 answers

Why is NP only a set of decision problems?

Taken from Wikipedia but all definitions I have seen are similar to this: "NP is the set of decision problems where the "yes"-instances can be accepted in polynomial time by a non-deterministic Turing machine." Why is NP restricted to only…
jarnald
  • 41
  • 4
3
votes
0 answers

P and NP complete problems

I am studying Automata theory.I am little confuse in How to problem is in P or NP complete problems. I did not know understand whether P = NP ? can someone clear my confusion about these problems.
Robin
  • 43
  • 1
  • 5
3
votes
2 answers

SQL query to find rows with the most matching keywords

I'm really bad at SQL and I would like to know what SQL I can run to solve the problem below which I suspect to be a NP-Complete problem but I'm ok with the query taking a long time to run over large datasets as this will be done as a background…
Shane Rowatt
  • 1,951
  • 3
  • 27
  • 44
3
votes
0 answers

Study: NP-Completeness Using Hamiltonian Path

I'm preparing for exams and for my algorithms course we've been needing to cover NP completeness but we never had any real tutorials for them and just got given a pile of "practice questions" for the exam. I've worked through all but the last and…
Syzorr
  • 587
  • 1
  • 5
  • 17
3
votes
2 answers

NP-Complete reduction

The problem states that we want to show that Independent Set poly-time reduces to Relative Prime Sets, more formally Independent Set

Rumen Hristov
  • 867
  • 2
  • 13
  • 29
3
votes
1 answer

when a given graph is 3-colorable?

I want to use graph 3-colorability to prove a problem is NP-complete But I'm not sure when a given graph is 3-colorable. I think if it doesn't have any node to be connected to all 3 vertices of a triangle in the graph.But i'm not sure. is it…
user3070752
  • 694
  • 4
  • 23
3
votes
1 answer

Subset sum algorithm a little faster than 2^(n/2) in worst time?

After analyzing the fastest subset sum algorithm which runs in 2^(n/2) time, I noticed a slight optimization that can be done. I'm not sure if it really counts as an optimization and if it does, I'm wondering if it can be improved by…
omega
  • 40,311
  • 81
  • 251
  • 474
3
votes
1 answer

Modification to subsetsum algorithm by pisinger

I was looking at the algorithm by pisinger as detailed here Fast solution to Subset sum algorithm by Pisinger and on wikipedia http://en.wikipedia.org/wiki/Subset_sum_problem For the case that each xi is positive and bounded by a fixed constant C,…
omega
  • 40,311
  • 81
  • 251
  • 474
3
votes
1 answer

Complexity measurement of NP-complete

For example, the set-cover decision problem is known to be a NP-complete problem. The input of this problems is a universe U, a family S of subsets of U, and an integer k (). One thing that I'm confused with is that if we let k=1, then obviously…
kostio
  • 33
  • 4