NP-hard problems (Non-deterministic Polynomial-time hard problems) are those problems which are not easier than any problem in NP; in other words, an algorithm for an NP-hard problem can be used to solve any problem in NP by transforming the input in polynomial time. Problems which are in both NP-Hard and NP are known as NP-Complete.
Questions tagged [np-hard]
178 questions
8
votes
7 answers
How to find what numbers in a set add up to another given number?
Here's a problem that I seem to be running into working with an accounting system.
I have a set of transactions, but their sum does not equal the amount that the accounting department thinks that it should. They are not questioning the math, just…

Even Mien
- 44,393
- 43
- 115
- 119
7
votes
1 answer
List of problems that are in general NP-hard but have polynomial-time solution in planar graphs?
I encountered many problems that can be formulated as graph problem.
It is in general NP-hard but sometimes the graph can be proved to be planar.
Hence, I am interested in learning these problems and the algorithms.
So far as I know:
Max cut in…

Ivan Xiao
- 1,919
- 3
- 19
- 30
6
votes
1 answer
How to do Binary Encoding in Genetic Algorithm for better results in Timetable Scheduling Problem?
I have a problem of University Timetable Scheduling which I am trying to solve with Genetic Algorithm. I want to know the best encoding type for this problem that can also help me in satisfying few of the constraints. For this problem, the timetable…

Awais Shahid
- 117
- 4
- 15
6
votes
2 answers
Why is TSP NP-hard while the Hamiltonian path NP-complete?
Why aren't these 2 problems, namely TSP and Hamiltonian path problem, both NP-complete?
They seem identical.

User
- 23,729
- 38
- 124
- 207
5
votes
3 answers
NP-Complete vs. NP-hard
If a problem A known to be NP-Complete can be reduced to another problem B in polynomial time then B is
(A) NP-Complete
(B) NP-hard
Nothing is given about problem B whether it is in NP or not. I'm confused because in Hopcraft and Ullman book there…

Prashant Bhardwaj
- 1,203
- 2
- 18
- 26
5
votes
1 answer
Selecting k sub-posets
I ran into the following algorithmic problem while experimenting with classification algorithms. Elements are classified into a polyhierarchy, what I understand to be a poset with a single root. I have to solve the following problem, which looks a…

dareios
- 1,389
- 2
- 11
- 10
4
votes
3 answers
Is this a linear programming problem?
I have been pulling my hair out on one problem... The overall problem is complicated... but let me try my best to explain the part that really matters...
I have a graph where each edge represents the correlation between the connected two nodes. Each…

h0cked
- 63
- 1
- 6
4
votes
2 answers
What is the minimum number of swaps needed so that the difference of sums of arrays a and b is minimum?
Given 2 arrays of integers a[] and b[] with the same size of n (1 <= n <= 100) numbered from 1 to n.
(0 <= a[i], b[i] <= 6)
You can swap any a[i] with b[i].
What is the minimum number of swaps needed so that the difference of the sums of array a[]…

unglinh279
- 675
- 4
- 24
3
votes
3 answers
Fast approximation of simple cases of relaxed bipartite dimension of graph problem
Given boolean matrix M, I need to find a set of submatrices A = {A1, ..., An} such that matrices in A contain all True values in matrix M and only them. Submatrices don't have to be continuous, i.e. each submatrix is defined by the two sets of…

Dimitrius
- 564
- 6
- 21
3
votes
3 answers
fair partitioning of set S into k partitions
There is a set S containing N integers each with value 1<=X<=10^6. The problem is to partition the set S into k partitions. The value of a partition is the sum of the elements present in it. Partition is to be done in such a way the total value of…

Akhil
- 2,269
- 6
- 32
- 39
3
votes
1 answer
How hard is this in terms of computational complexity?
So I have a problem that is basically like this: I have a bunch of strings, and I want to construct a DAG such that every path corresponds to a string and vice versa. However, I have the freedom to permute my strings arbitrarily. The order of…

danharaj
- 1,613
- 14
- 19
3
votes
0 answers
Multiple Knapsack using Dynamic Programming
I'm wondering if there is a reasonable way of solving Multiple Knapsack using DP. I get the point in 0-1 Knapsack Problem. The recurrence is quite straightforward, add item/ not add item.
dp[item][capacity] = max{
value[item] + dp[item -…

André Gomes
- 185
- 13
3
votes
1 answer
What do you call the property of a list that describes the degree to which it contains duplicates?
I have a function that selects Cartesian products of lists such that the number of duplicate elements is highest:
import Data.List (nub)
f :: Eq a => [[a]] -> [[a]]
f xss = filter ((==) minLength . length . nub) cartProd
where
minLength =…

marc_r
- 160
- 7
3
votes
1 answer
Fast Exact Solvers for Chromatic Number
Finding the chromatic number of a graph is an NP-Hard problem, so there isn't a fast solver 'in theory'. Is there any publicly available software that can compute the exact chromatic number of a graph quickly?
I'm writing a Python script that…

Chris Harshaw
- 155
- 5
3
votes
2 answers
Single candidate and multiple interviewers?
There is 1 candidate who is to be interviewed by the n interviewers, so a total of n consecutive slots are needed for the same, for example The table below illustrates the availability of four interviewers (I1, I2, I3, I4) at four time slots (S1,…
user3752338