Optimizing Merge Sort
On modern computers, locality of reference can be of paramount importance in software optimization, because multilevel memory hierarchies are used. Cache-aware versions of the merge sort algorithm, whose operations have been specifically chosen to minimize the movement of pages in and out of a machine's memory cache, have been proposed. For example, the tiled merge sort algorithm stops partitioning subarrays when subarrays of size S are reached, where S is the number of data items fitting into a CPU's cache. Each of these subarrays is sorted with an in-place sorting algorithm such as insertion sort, to discourage memory swaps, and normal merge sort is then completed in the standard recursive fashion. This algorithm has demonstrated better performance on machines that benefit from cache optimization. (LaMarca & Ladner 1997)
Kronrod (1969) suggested an alternative version of merge sort that uses constant additional space. This algorithm was later refined. (Katajainen, Pasanen & Teuhola 1996).
Also, many applications of external sorting use a form of merge sorting where the input get split up to a higher number of sublists, ideally to a number for which merging them still makes the currently processed set of pages fit into main memory.
Read more about this topic: Merge Sort
Famous quotes containing the words merge and/or sort:
“I too but signify at the utmost a little washd-up drift,
A few sands and dead leaves to gather,
Gather, and merge myself as part of the sands and drift.”
—Walt Whitman (18191892)
“This sort of gingerbread is baked daily and more sedulously than pure wheat or rye- and-Indian in almost every oven, and finds a surer market.”
—Henry David Thoreau (18171862)