TADM2E 2.49

From Algorithm Wiki
Revision as of 18:18, 13 November 2016 by Brandon.arnold (talk | contribs)
Jump to: navigation, search

Assuming pairwise merges (no k-way merges) we have $ n-1 $ merge stages where each set of companies is generated from the previous stage (the merged pair being one company). If we characterize each complete merge as different if two companies merge at different stages then we are looking at combinations. In the first stage we have $ \binom{n}{2} $ ways to choose a merge pair and a new set for the next stage. Thus, we have the Cartesian product of each stage set and we can calculate the size as:

$ \prod_{i=2}^{n} \frac{i(i-1)}{2} = \frac{n! (n-1)!}{2^{n-1}} $

Proof by induction follows easily as long as we agree with the counting process for first non-trivial basis (i.e. $ n=3 $ where our formula indicates there are three different possible merges):

{a,b,c} -> {ab, c} -> {abc}
        -> {a, bc} -> {abc}
        -> {ac, b} -> {abc}

And, since we have three paths we can say that's three merges -- this counts a merge step as the same if it results in the same set of companies going on to the next stage. But, instead if we count the actual merge operations:

{a, b, c} -> {a+b, c}, {(a+b) + c}, {a, b+c}, {a + (b+c)},
             {a+c, b}, {(a+c) + b}

then we need to change the denominator in our previous formula:

$ 2^{n-1} \rightarrow 2^{n-2} $ to get six steps.