partition-problem

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

∥☆過路亽.° 提交于 2019-12-02 18:37:56
问题 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 the sums cannot be equal, the smaller set should have the larger sum. That would be the optimal solution, but I only really need an exact solution on the subset size constraints. The difference of sums doesn't strictly need to be minimal, but

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

柔情痞子 提交于 2019-12-02 12:30:50
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 the sums cannot be equal, the smaller set should have the larger sum. That would be the optimal solution, but I only really need an exact solution on the subset size constraints. The difference of sums doesn't strictly need to be minimal, but should come close. Also I would prefer if the smaller set (if any) has the larger sum. I realize this may be

Finding maximum valued subset in which PartitionProblem algorithm returns true

ⅰ亾dé卋堺 提交于 2019-12-01 12:16:37
I´ve got the following assignment. You have a multiset S with of 1<=N<=22 elements. Each element has a positive value of up to 10000000. Assmuming that there are two subsets s1 and s2 of S in which the sum of the values of all the elements of one is equal to the sum of the value of all the elements of the other and it is the highest possible value. I have to return which elements of S would not be included in either of the two subsets. Its probably been solved before, I think its some variant of the Partition problem but I can´t find it. If anyone could point me in the right direction that´d

Finding maximum valued subset in which PartitionProblem algorithm returns true

给你一囗甜甜゛ 提交于 2019-12-01 09:29:04
问题 I´ve got the following assignment. You have a multiset S with of 1<=N<=22 elements. Each element has a positive value of up to 10000000. Assmuming that there are two subsets s1 and s2 of S in which the sum of the values of all the elements of one is equal to the sum of the value of all the elements of the other and it is the highest possible value. I have to return which elements of S would not be included in either of the two subsets. Its probably been solved before, I think its some variant

Print all unique integer partitions given an integer as input

拜拜、爱过 提交于 2019-11-30 04:34:20
I was solving a programming exercise and came across a problem over which I am not able to satisfactorily find a solution. The problem goes as follows: Print all unique integer partitions given an integer as input. Integer partition is a way of writing n as a sum of positive integers. for ex: Input=4 then output should be Output= 1 1 1 1 1 1 2 2 2 1 3 4 How should I think about solving this problem? I was wondering about using recursion. Can anyone provide me an algorithm for this question? Or a hint towards solution. any explanation for such kind of problems is welcome. (I am a beginner in

Print all unique integer partitions given an integer as input

北慕城南 提交于 2019-11-29 01:58:01
问题 I was solving a programming exercise and came across a problem over which I am not able to satisfactorily find a solution. The problem goes as follows: Print all unique integer partitions given an integer as input. Integer partition is a way of writing n as a sum of positive integers. for ex: Input=4 then output should be Output= 1 1 1 1 1 1 2 2 2 1 3 4 How should I think about solving this problem? I was wondering about using recursion. Can anyone provide me an algorithm for this question?

3-PARTITION problem

为君一笑 提交于 2019-11-28 06:36:56
here is another dynamic programming question ( Vazirani ch6 ) Consider the following 3-PARTITION problem. Given integers a1...an, we want to determine whether it is possible to partition of {1...n} into three disjoint subsets I, J, K such that sum(I) = sum(J) = sum(K) = 1/3*sum(ALL) For example, for input (1; 2; 3; 4; 4; 5; 8) the answer is yes, because there is the partition (1; 8), (4; 5), (2; 3; 4). On the other hand, for input (2; 2; 3; 5) the answer is no. Devise and analyze a dynamic programming algorithm for 3-PARTITION that runs in time poly- nomial in n and (Sum a_i) How can I solve

Getting all possible sums that add up to a given number

耗尽温柔 提交于 2019-11-27 12:14:55
I'm making an math app for the android. In one of these fields the user can enter an int (no digits and above 0). The idea is to get all possible sums that make this int, without doubles (4+1 == 1+4 in this case). The only thing known is this one int. For example: Say the user enters 4, I would like the app to return: 4 3+1 2+2 2+1+1 1+1+1+1 Obviously 4 == 4 so that should be added too. Any suggestions as to how i should go about doing this? Here's a simple algorithm that purports to do that from : http://introcs.cs.princeton.edu/java/23recursion/Partition.java.html public class Partition {

3-PARTITION problem

谁说我不能喝 提交于 2019-11-27 01:25:18
问题 here is another dynamic programming question (Vazirani ch6) Consider the following 3-PARTITION problem. Given integers a1...an, we want to determine whether it is possible to partition of {1...n} into three disjoint subsets I, J, K such that sum(I) = sum(J) = sum(K) = 1/3*sum(ALL) For example, for input (1; 2; 3; 4; 4; 5; 8) the answer is yes, because there is the partition (1; 8), (4; 5), (2; 3; 4). On the other hand, for input (2; 2; 3; 5) the answer is no. Devise and analyze a dynamic

Getting all possible sums that add up to a given number

跟風遠走 提交于 2019-11-26 15:57:05
问题 I'm making an math app for the android. In one of these fields the user can enter an int (no digits and above 0). The idea is to get all possible sums that make this int, without doubles (4+1 == 1+4 in this case). The only thing known is this one int. For example: Say the user enters 4, I would like the app to return: 4 3+1 2+2 2+1+1 1+1+1+1 Obviously 4 == 4 so that should be added too. Any suggestions as to how i should go about doing this? 回答1: Here's a simple algorithm that purports to do