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

Double exponential problems?

Are there any significant problems in computer science that can only be solved in double exponential time ? And if they exist then to which class of problems do they belong ?
Nikunj Banka
  • 11,117
  • 16
  • 74
  • 112
5
votes
5 answers

Are all NP problems also NP-complete?

The definition of NP-complete is A problem is NP-complete if it belongs to class NP all the other problems in NP polynomially transform to it So, if all other problems in NP transform to an NP-complete problem, then does that not also mean that…
entitledX
  • 670
  • 1
  • 7
  • 13
5
votes
4 answers

What makes an NP-hard problem not to be an NP-complete problem?

I am having confusion about NP-hard problems. Some NP-hard problems are in NP which are called NP-Complete and some are not in NP. For ex : Halting problem is only NP-hard, not NP-complete. But why it is not NP-complete ? I mean what property should…
Happy Mittal
  • 3,667
  • 12
  • 44
  • 60
5
votes
1 answer

What is a "Natural" NP-Complete prob?

I think I have a pretty decent understanding of NP-Complete, NP-Hard, etc. in general, but all of a sudden, stumbling upon some literature, I found someone saying a "natural" NP-complete problem -- explicitly with those quotes. I didn't understand…
vawd_gandi
  • 85
  • 6
5
votes
0 answers

Matching students to courses with course limit (Hungarian, Max Flow, Min-Cost-Flow, ...)

I am currently writing a program which maps students to courses. Currently, I am using a SAT-Solver, but I am trying to implement a polynomial time / non greedy algorithm which solves the following sub-problem: There are students (50-150) There are…
5
votes
1 answer

NP-Completeness in Task Scheduling

So this is a bit of a thought provoking question to get across the idea of NP-Completeness by my professor. I get WHY there should be a solution, due to the rules of NP-Completeness, but I don't know how to find it. So here is the problem: The…
5
votes
4 answers

Polynomial-time algorithm for travelling salesman in a grid

I have read that the classic travelling salesman problem (TSP) is NP-Hard. And there are some approximation algorithms and also a specific algorithm running in O(N^2 * 2^N) time. But AFAIK, these are for TSP in a general graph. So my question, is…
Roshnal
  • 1,284
  • 3
  • 16
  • 39
5
votes
1 answer

Is integration np, np complete, np hard or none of the above?

It is sometimes very difficult to evaluate an integral, but easy enough to verify if the solution is correct. Seems to me like it should at least be np, but my understanding of the concept is limited and I might be missing something Edit: just to be…
kevingregg
  • 101
  • 4
4
votes
2 answers

Algorithm to find combination of signs of integers in a set such that the set sums to 0

Given a set S of n positive integers, we want to know if we can find a combination of signs for each of the numbers in S (+ or -) such that the sum of S is 0. How can one efficiently solve this problem? Based on similar problems, I'd imagine some…
Simon H
  • 374
  • 2
  • 14
4
votes
1 answer

Why all NP-complete problems can be reducible to 3-SAT?

When I tried to figure out why halting-problem is NP-hard, I found this. However, there is a statement confuse me We begin by noting that all NP-complete problems are reducible to 3SAT. Why all NP-Complete problems can be reducible to 3-SAT? Hope…
Zheyuuu
  • 151
  • 1
  • 12
4
votes
4 answers

most suitable language for computationally and memory expensive algorithms

Let's say you have to implement a tool to efficiently solve an NP-hard problem, with unavoidable possible explosion of memory usage (the output size in some cases exponential to the input size) and you are particularly concerned about the…
4
votes
1 answer

Using a giant hashtable to solve a sudoku in polynomial time

Say you were to create a hash table that maps every possible valid 9x9 sudoku (not yet filled in) to its solution. (as infeasible a task as this would be) Then you were to create a simple program that takes a valid 9x9 sudoku (again, not yet filled…
svaerth
  • 61
  • 1
  • 5
4
votes
1 answer

How can 3-SAT be reduced to Independent set?

I was reading about NP hardness from here (pages 8, 9) and in the notes the author reduces a problem in 3-SAT form to a graph that can be used to solve the maximum independent set problem. In the example, the author converts the following 3-SAT…
Arat254
  • 449
  • 2
  • 5
  • 17
4
votes
1 answer

Is generating all strings permutation NP Complete?

Calculating all string permutations of a given string can be solved in O(n!) by trying all possibilities. Now, looking at the Travel Salesman Problem, we can solve it by trying all permutations of cities. Lets say we have cities A, B and C. Lets say…
fredcrs
  • 3,558
  • 7
  • 33
  • 55
4
votes
1 answer

Pandas series case-insensitive matching and partial matching between values

I have the following operation to add a status showing where any string in a column of one dataframe column is present in a specified column of another dataframe. It looks like this: df_one['Status'] = np.where(df_one.A.isin(df_two.A),…
user3535074
  • 1,268
  • 8
  • 26
  • 48
1 2
3
32 33