开发者

C algorithm for Partition issues

Given a set of integers S:

How can the set be divided into k parts such that the sum of each part is minimal? Please give also a C implementa开发者_运维问答tion.

Example:

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

The partition

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

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


This page describes the problem fairly well and even provides pseudocode for an algorithm:

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


Determine min, max in the given list and form a pair. Repeat until the list is exhausted.

Intuitively it seems it will ensure the desired result, but not sure though!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜