C algorithm for partition problems

Given the set of integers S:

How can one divide a set into k parts so that the sum of each part is minimal? Please also give an implementation of C

Example:

 S = {1, 2, 3, 4, 5, 6} and k = 3 

Section

  S1 = {1, 6} S2 = {2, 5} S3 = {3, 4} 

possesses the property that the sum of each partition is minimal.

+4
source share
2 answers

This page describes the problem pretty well and even provides pseudo-code for the algorithm:

http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM

+2
source

Define min, max in this list and form a pair. Repeat until the list is exhausted.

It seems intuitively that this will provide the desired result, but not sure though!

0
source

Source: https://habr.com/ru/post/1344684/


All Articles