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

Factorizing an integer in a list of integers

I am trying to write a script that determines whether it is possible to factorize an integer value in a list of integers. The way I have done it is to search recursivley for a valid factorization, effectiveley doing a DFS in a tree of possible…
Meldrin
  • 1
  • 2
0
votes
1 answer

Prove no such algorithm exists

I am studying algorithms and I came across this exercise: 'Prove that there is no program/algorithm that determines if a program P uses an uninitialized variable on a given input x.' Here is the proof I came up with: Let's assume that there is an…
a_123
  • 183
  • 2
  • 13
0
votes
1 answer

Judge whether exist a simple path visiting certain node?

Given a graph , starting node st, end node ed and certain node set M that must be visited. My question is to find the simple path that visiting all the M. Also I want to know: 1 Is the path exist? 2 If exists, how to find it as fast as…
mickeyandkaka
  • 1,452
  • 2
  • 11
  • 21
0
votes
1 answer

Find minimum weighted set

I'm facing a deadend. Already searched trough stack forum, hope the question has not Already been asked.. I have a univers called U ( with Many elements). I have N sets containing several elements from U. We can find same element in different…
Choco52
  • 11
  • 3
0
votes
2 answers

Memory error when using read_csv

I'd like to convert the csv files into hdf5 format,which are used for caffe training.Because the csv files is 80G,it will report memory error.The machine memory is 128G.So can it possbile to improve my code?handle it one by one?Below is my code,it…
刘米兰
  • 183
  • 2
  • 11
0
votes
2 answers

Schedule Maximum Number Tasks That have Fixed Start and End times

I am trying to create a schedule function that uses only python built-in modules that will return the maximum number of non overlapping appointments. The function's input is a list of lists, the inner list contains 2 integer elements, the start and…
veda905
  • 782
  • 2
  • 12
  • 32
0
votes
1 answer

Updating the matrix of paths in the graph

I have this matrix that hold path between vertexes.for example for 4 vertex we have the matrix like this : 0 0 1 1 1 0 1 1 0 0 0 1 0 0 0 0 That shows us we have path between (1,3) & (1,4) & (2,1) & (2,3) & (2,4) & (3,4). The input of my problem is…
0
votes
1 answer

Definition of NP Complete

I'm trying to understand the formal definition of NP Complete and had some questions. I was wondering if someone can provide more insight. The Jon Kleinberg algorithms book says that if every NP problem can be reduced to a problem X, then problem X…
AggieMan
  • 84
  • 8
0
votes
1 answer

optimizing Brute-force TSP solution

I'm working on a small project for solving TSP but am experiencing a problem. The idea is to optimize a local part of a non-optimal path by simply finding the best combination. This is accomplished by a simple recursive permutation generating…
Greenmachine
  • 292
  • 1
  • 15
0
votes
2 answers

Is it normal to solve a TSP with GA(Genetic Algorithyms) implementation takes much time?

I am working on GA for a project. I am trying to solve Travelling Salesman Problem using GA. I used array[] to store data, I think Arrays are much faster than List. But for any reason it takes too much time. e.g. With MaxPopulation = 100000,…
Ali Tor
  • 2,772
  • 2
  • 27
  • 58
0
votes
1 answer

An algorithm to prove that for a constant K, K-Clique in P?

I am a newbie in theoretical computer and I was asked to do such an algorithm that works in a polynomial time for K-CLIQUE to prove that it belongs to P. I was thinking about an algorithm that takes a graph of n vertex, and for each vertex , for…
Zok
  • 355
  • 2
  • 15
0
votes
1 answer

P NP and NP complete clarfication?

This is an answer I found on stack overflow NP is a complexity class that represents the set of all decision problems for which the instances where the answer is "yes" have proofs that can be verified in polynomial time. This means that if someone…
Squaddy
  • 11
  • 2
0
votes
1 answer

Tile Trial NP-hard complexity

In the game Final Fantasy XIII-3, the player is presented with a couple puzzles. The first puzzle introduced is called Tile Trial, which presents the player with a grid of tiles, some of which have crystals on them. The goal is to retrieve all of…
G. Zuin
  • 1
  • 2
0
votes
1 answer

Is mapping array elements to perfect hash indexes NP Complete?

Assuming I have a set of integers that can range from 0 to INT64MAX, but I know the set in its entirety so I can generate a perfect hash. If I want to use these hashes as array indices, I need to modulus with the size of the array I want to store…
halivingston
  • 3,727
  • 4
  • 29
  • 42
0
votes
1 answer

Truth Table too big to compute

I have a boolean condition parsed like this: (a v b) ^ (c ^ d)... with the elements on a list. Counting both variables, brackets and operators the list is around a thousand elements long. There are around 80 variables in the condition. I have tried…