Questions tagged [partition-problem]

In computer science, the partition problem is to decide whether a given multiset of integers can be partitioned into two "halves" that have the same sum.

In computer science, the partition problem is an NP-complete problem. The problem is to decide whether a given multiset of integers can be partitioned into two "halves" that have the same sum. More precisely, given a multiset S of integers, is there a way to partition S into two subsets S1 and S2 such that the sum of the numbers in S1 equals the sum of the numbers in S2? The subsets S1 and S2 must form a partition in the sense that they are disjoint and they cover S.

The optimization version asks for the "best" partition, and can be stated as: Find a partition into two subsets S1,S2 such that max(operatorname{sum}(S_1), operatorname{sum}(S_2)) is minimized (sometimes with the additional constraint that the sizes of the two sets in the partition must be equal, or differ by at most 1).

The partition problem is equivalent to the following special case of the subset sum problem: given a set S of integers, is there a subset S1 of S that sums to exactly t /2 where t is the sum of all elements of S? (The equivalence can be seen by defining S2 to be the difference S − S1.) Therefore, the pseudo-polynomial time dynamic programming solution to subset sum applies to the partition problem as well.

A variation of the partition problem is the 3-partition problem, in which the set S must be partitioned into |S|/3 triples each with the same sum. In contrast to partition, 3-partition has no pseudo-polynomial time algorithm unless P = NP: 3-partition remains NP-complete even when using unary coding.

58 questions
0
votes
2 answers

Divide set of values into two sets of same or similar size with similar value sums

I have a set of floating point values that I want to divide into two sets whose size differs at most by one element. Additionally, the difference of value sums between the two sets should be minimal. Optionally, if the number of elements is odd and…
Wormbo
  • 4,978
  • 2
  • 21
  • 41
0
votes
1 answer

Sum or difference of numbers in a set greater or equal to a number

I have a problem that states the following: Given a sequence of numbers (S), an initial value (V) and a target value (T), check if there is a sequence of + and - operations that can be assigned to the sequence S (the operations must respect the…
0
votes
1 answer

Given a set of 20 distinct positive integers, find two subsets that have the same sum

For example, if A = {10, 20, 30, 40, ..., 200}, then {10, 20, 30, 40, 100} and {90, 110} are two subsets that have the same sum (which is 200). Since the length of input is only 20? Can't we simply generate all combinations of the numbers , compute…
user1071840
  • 3,522
  • 9
  • 48
  • 74
0
votes
0 answers

Strange issue with custom email template in magento

Hi for some need i need to set up a new email template with new header and footer with for this i have create a new template in configuration->transaction emails and crate a new template with the following code
Rohit Goel
  • 3,396
  • 8
  • 56
  • 107
0
votes
2 answers

SQL: Failing to bring back effective begin/end dates on order by/partition by query

I want to bring back a result set that returns the beginning effective date and the end effective date for an id with multiple supplier changes. To do this, I am looking at a transaction table that records the id, the supplier's id and the date the…
plditallo
  • 701
  • 2
  • 13
  • 31
0
votes
1 answer

PartitionProblem - find the optimal subsets

I need to find the optimal subsets after solving the partition problem using the Dynamic Programming pseudo polynomial time algorithm. More specifically, I'm not able to make sense of this answer: https://stackoverflow.com/a/890243/1317826 I'm not…
0
votes
1 answer

PartitionProblem variation - fixed size of subsets

I have a problem which is a variation of the partition problem which is NP-complete. This is an optimization problem, not a decision problem. Problem: Partition a list of numbers into two subsets such that their difference of sums is minimum, and…
Bruce
  • 945
  • 3
  • 12
  • 24
0
votes
1 answer

Get partition details in diskperf

In diskperf filter driver how can I get the partition info of all the partitions. I am using IOCTL_DISK_GET_DRIVE_LAYOUT_EX ioctl to get the partition information. I am able to get details of partitions from one disk. But if there are more then one…
0
votes
4 answers

how can i find partitions of given list?

how can i find all partitions of list of integers? mostly i need algorithm that uses recursion as i'm gonna implement it in SML. i need just algorithm, i will do coding part by myself. by mistake i wrote code for finding subsets and i don't have too…
unknown
  • 33
  • 1
  • 5
0
votes
2 answers

Calling a function in matlab

I have a MinCUT Algorithm In matlab. It is a function! How do I call it from my mail file! Do I have to define all the variables? Or do I have to define just the Inputs? function [MinCutGroupsList, MinCutWeight] = MinCut(SourceNodes,…
happyme
  • 233
  • 2
  • 5
  • 16
-1
votes
10 answers

Check if a number can be divided into prime partitions

Can somebody solve this problem on Python ? A positive integer m can be partitioned as primes if it can be written as p + q where p > 0, q > 0 and both p and q are prime numbers. Write a Python function that takes an integer m as input and returns…
Souvikavi
  • 108
  • 1
  • 10
-1
votes
1 answer

Grouping using analytical functions in Oracle

I've got a table with the columns: col1 (primary key) number col2 number - contains few duplicates This table contains 600 records. I'm trying to construct a query where the user can give any group count (max no of records in a group. Eg: 11).…
ragav
  • 66
  • 7
-2
votes
1 answer

Divide linked-list into 2 sublists with equal sum

I'm trying to divide a linked-list into 2 sublists with equal sum. These sublists do not need to consist of consecutive elements. I have a linked list as Eg.1 LinkedList={1,7,5,5,4} should be divided into LinkedList1={1,5,5} LinkedList2={7,4} Both…
1 2 3
4