I have an big array of length N, let\'s say something like:
2 4 6 7 6 3 3 3 4 3 4 4 4 3 3 1
I need to split this array into P subarrays (in
Your problem is very similar to, or the same as, the minimum makespan scheduling problem, depending on how you define your objective. In the case that you want to minimize the maximum |sum_i - sigma|
, it is exactly that problem.
As referenced in the Wikipedia article, this problem is NP-complete for p > 2
. Graham's list scheduling algorithm is optimal for p <= 3
, and provides an approximation ratio of 2 - 1/p
. You can check out the Wikipedia article for other algorithms and their approximation.
All the algorithms given on this page are either solving for a different objective, incorrect/suboptimal, or can be used to solve any problem in NP :)