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
11
votes
3 answers

The complexity of verifying solutions to NP-hard optimization problems?

There are many optimization problems that are known to be NP-hard, such as the traveling salesman problem, MAX-SAT, or finding the minimum chromatic number of a graph. Given a problem of this sort, I'm curious about the complexity of the following…
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
10
votes
5 answers

Is this solvable in polynomial (or pseudo-polynomial) time?

I'm trying to come up with a reasonable algorithm for this problem: Let's say you have a bunch of balls. Each ball has at least one color, but can also be multicolored. Each ball has a weight and a value associated with it. There are also a bunch of…
8
votes
1 answer

P=NP: What are the most promising methods?

I know that P=NP has not been solved up to now, but can anybody tell me something about the following: What are currently the most promising mathematical / computer scientific methods that could be helpful to tackle this problem? Or are there even…
phimuemue
  • 34,669
  • 9
  • 84
  • 115
7
votes
2 answers

Maximum Independent Set Algorithm

I don't believe there exists an algorithm for finding the maximum independent vertex set in a bipartite graph other than the brute force method of finding the maximum among all possible independent sets. I am wondering about the pseudocode to find…
user1084113
  • 932
  • 3
  • 15
  • 31
7
votes
1 answer

Finding a subset which satisfies a certain condition

I have several arrays of numbers (each element of the array can only take a value of 0 or 1) like this v1: 1; 0; 0; 1; 1; v2: 0; 1; 0; 0; 1; v3: 1; 1; 0; 1; 0; v4: 1; 0; 0; 1; 0; v5: 1; 1; 0; 1; 1; v6: 1; 1; 0; 1; 1; I wish to find subsets…
Neo
  • 1,554
  • 2
  • 15
  • 28
7
votes
1 answer

How to find pattern groups in boolean array?

Given a 2D array of Boolean values I want to find all patterns that consist of at least 2 columns and at least 2 rows. The problem is somewhat close to finding cliques in a graph. In the example below green cells represent "true" bits, greys are…
Serge
  • 1,531
  • 2
  • 21
  • 44
7
votes
3 answers

Complete Weighted Graph and Hamiltonian Tour

I ran into a question on a midterm exam. Can anyone clarify the answer? Problem A: Given a Complete Weighted Graph G, find a Hamiltonian Tour with minimum weight. Problem B: Given a Complete Weighted Graph G and Real Number R, does G have a…
user4559497
7
votes
1 answer

Implementing a backtrack search with heuristic?

I'm getting quite interested in search algorithms and backtrack programming. For now, I have implemented Algorithm X (see my other post here: Determine conflict-free sets? ) to solve an exact cover problem. This works very well but I'm now…
user26372
  • 129
  • 1
  • 2
  • 14
7
votes
2 answers

Is "house coloring with three colors" NP?

Consider the problem described here (reproduced below.) Can some better known NP-complete problem be reduced to it? The problem: There are a row of houses. Each house can be painted with three colors: red, blue and green. The cost of painting…
user977476
7
votes
2 answers

can some sorting be P, NP, and NP-Complete?

I am quite confused, and this is my thought after some reading: P is in NP and NP is in NP-Complete. Therefore, all P could be in NP and NP-Complete? Does that mean there are sorting algorithms that could be NP and NP-Complete? Hope this…
Chaos
  • 307
  • 1
  • 4
  • 13
6
votes
2 answers

How is 2-CNF SAT is in P, while 3-CNF SAT is in NPC?

I am really confused why 2-CNF SAT is in P, while 3-CNF SAT is in NPC. I Read CLRS, and I understand how they prove 3-CNF SAT is in NPC. Can't I use the same reducibility from SAT to 2-CNF-SAT to prove 2-CNF-SAT is in NPC. I don't understand why…
Rave
  • 835
  • 4
  • 15
  • 28
6
votes
0 answers

How to cover a rectangle area with irregular shapes and no holes

I have detailed, highly irregular shapes like these: and I'm looking for a way to make them cover a rectangle area with no holes and minimal blend/cover between shapes. Limited up-scaling and free rotation is also allowed. I searched through…
6
votes
3 answers

matrices are not aligned error message

I have the following dataframe of returns ret Out[3]: Symbol FX OGDC PIB WTI Date 2010-03-02 0.000443 0.006928 0.000000 0.012375 2010-03-03 -0.000690 -0.007873 0.000171 …
John
  • 531
  • 1
  • 8
  • 23
6
votes
1 answer

Complete Weighted Graph G, Finding Weights and one Machine

I read a lot about Complete Weighted Graph and Hamiltonian Tour topics in this site that asked by one of users, ask a lots of staff in my university, but couldn't get to a good answer, I change an important part of this question as follows:…
user4249446
6
votes
1 answer

NP-Complete? Optimal graph embedding for a graph with specific constraints

I have a grid based graph, where nodes and edges occupy cells. Edges can cross, but cannot travel on top of each other in the same direction. Lets say I want to optimize the graph so that the distance covered by edges is minimized. I am currently…
ddriver1
  • 723
  • 10
  • 18
1
2
3
32 33