algorithm - Partition of a set into K disjoint subsets with equal sum -


given n ( n <= 20) non-negative numbers. there / can there algorithm acceptable time complexity determines whether n numbers can divided k ( k <= 10) disjoint subsets, such each subset has equal sum?

one way improve on brute force method:

s = sum of numbers = 2 10   k = s /    if k integer     partitions of input array minimum subset size of 2 elements , maximum of n-1 elements.     check each partition it's generated see if subsets have same sum.     end if    next 

the hard (and slow) part generating partitions. can recursive function. shouldn't unreasonably slow partitioning 20 numbers. can optimize partition generation throwing out partitions unequal subset sums early.


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -