Mergesort is one of the canonical DivideAndConquer algorithms. Pseudocode can be found in almost any algorithms textbook (e.g. LevitinBook, page 124). Running time is given by the recurrence T(n) = 2T(n/2) + Theta(n), which has solution T(n) = Theta(n log n).

The usual implementation of merge requires Theta(n) extra space. It is possible to eliminate this overhead while retaining the O(n) running time for the merge. A description of one technique (citing Dokladi Akad. Nauk SSSR 186:1256-1258, 1969) is given as the answer to Exercise 5.2.4.18 on page 623 of volume 2 of KnuthSeries.

In practice QuickSort, which requires only O(log n) additional space and Theta(n log n) time on average, tends to be faster than MergeSort due to smaller constants. This guarantee is not absolute, however, because QuickSort is a randomized algorithm and may take as much as Theta(n^{2}) time (with absurdly low probability).