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
Post a Comment