I\'m currently reading The Algorithm Design Manual and I\'m stuck on this exercise.
Take a sequence of 2n real numbers as input. Design an O(n log n) algorithm tha
I think I can prove this for a sequence with no duplicated numbers, and it should be a reasonably simple exercise for the reader to extend the proof to non-unique sequences.
Pair x0, x2n together, then pair all other numbers according to an optimal solution.
Now consider the pairing of (x0, x2n) against any other pair xy, xz from the optimal subset. x2n + either xy or xz will be greater than xy+xz and also x2n+x0, therefore the pairing of x2n, x0 was optimal.
The proof now extends by induction to the pairing of X1, X2n-1, and further partitions of the subset, eventually producing the OP's pairing.