Suppose that there are n objects with different weights. We need to divide all objects in m sets. Let Si be sum of ith set, 1<= i <=m. Smax be maximum of all Si‘s. What can be the algorithm to minimize Smax over all possible divisions of n objects in m sets.
I have seen some algo which used Hungarian algorithm and bipartite graphs but could not understand that.
The problem you’re asking about is NP-Complete, as it can be reduced to the Partition Problem (and the 3-parition problem). To see why, suppose m = 2 and that the sum of weights of all objects is S. If the first set’s sum is S1, then obviously the the other set’s sum S2 = S – S1. Let’s prove that if we can make S1 and S2 equal (the solution to partition problem), then this is the optimal solution for your problem.
If S1 = S2 wasn’t optimal, that means that there exists some way of partitioning such that the first set has a sum S1‘ that would yield a better solution (a smaller maximum number). Let’s consider two cases:
Similarly, you can show how you can reduce you problem to the 3-paritition problem. However, there are some heuristics that can help in solving the partition problem, you can read about them in the Wikipedia pages I linked to earlier; I doubt there’s anything better than brute force for your more-generic version (unless there’s some kind of restriction you didn’t mention).
Hope that helped you in any manner!