Partitioning a set of items is a problem I run across rather often. Determining the number of ways you can partition a set of n items into k groups is a surprisingly difficult problem. Suppose you have a set of n = 4 items and want to partition those items into k = 2 groups. How many ways can you do this? There are 7 possible partitions of 4 items into 2 groups:

(a) (b,c,d)

(b) (a,c,d)

(c) (a,b,d)

(d) (a,b,c)

(a,b) (c,d)

(a,c) (b,d)

(a,d) (b,c)

(b) (a,c,d)

(c) (a,b,d)

(d) (a,b,c)

(a,b) (c,d)

(a,c) (b,d)

(a,d) (b,c)

It turns out that the number of possible partitions is given by an equation called Stirling numbers of the second kind, S(n,k). It is an interesting function which increases very rapidly. S(4,2) = 7 and S(6,4) = 65. I was working on a problem recently with n = 435 (the number of members in the U.S. House of Representatives) and k = 2. The number of ways you can partition 435 items into 2 groups is 4.4 * 10 to the 130th power. This is an unimaginably huge number. Wikipedia has a good article on Stirling numbers of the second kind if you want to know more.

Advertisements
(function(g){if("undefined"!=typeof g.__ATA){g.__ATA.initAd({sectionId:26942, width:300, height:250});
g.__ATA.initAd({sectionId:114160, width:300, height:250});}})(window);
var o = document.getElementById('crt-1402697768');
if ("undefined"!=typeof Criteo) {
var p = o.parentNode;
p.style.setProperty('display', 'inline-block', 'important');
o.style.setProperty('display', 'block', 'important');
Criteo.DisplayAcceptableAdIfAdblocked({zoneid:388248,containerid:"crt-1402697768",collapseContainerIfNotAdblocked:true,"callifnotadblocked": function () {var o = document.getElementById('crt-1402697768'); o.style.setProperty('display','none','important');o.style.setProperty('visbility','hidden','important'); }
});
} else {
o.style.setProperty('display', 'none', 'important');
o.style.setProperty('visibility', 'hidden', 'important');
}