Slideshow:
How should the objects be split ????
|
|
Therefore:
|
|
S = all possible subsets of {1 , 2, 3,...., n}; Initialize minArea: s1 ∈ S; // Pick the first subset in S best_A = s1 best_B = {1,2,3,...,n} - s; // Completement set minArea = AreaOfBB(objects in A) + AreaOfBB(objects in B); /* ================================================= Brute force: test every possible split... ================================================= */ for ( each subset s ∈ S - s1 ) do { A = s; B = {1,2,3,...,n} - s; Area = AreaOfBB(objects in A) + AreaOfBB(objects in B); if ( Area < minArea ) { minArea = Area; // New best !!! best_A = A; best_B = B; } } |
|
Running time of the naive (brute-force) algorithm:
Complexity of the naive re-distribute alg = O(2n-1) (# subsets of a set of n elements = 2n) (We need to consider half of all subsets due to symmetry) |
Abstractly:
1. Pick 2 "seed" objects e1 and e2 that are "as far apart" from each other as possible Group1 = { e1 }; Group2 = { e2 }; 2. while ( remaining elements ≠ ∅ ) { nextElem1 = the un-inserted element that will increase the BB of Group1 by the least amount nextElem2 = the un-inserted element that will increase the BB of Group2 by the least amount if ( increase in BB when adding nextElem1 to Group1 < increase in BB when adding nextElem1 to Group2 ) { Add nextElem1 to Group1; } else { Add nextElem2 to Group2; } } |
This O(n2) algorithm is described in this reference paper: click here