Merge Sort - Optimizing Merge Sort

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 wash’d-up drift,
    A few sands and dead leaves to gather,
    Gather, and merge myself as part of the sands and drift.
    Walt Whitman (1819–1892)

    I couldn’t find the spot where Frank had hidden the bag with the clothes. You can’t imagine how cold I was until I found them. You know, I’m beginning to understand why ghosts moan so in this sort of weather.
    Lester Cole (1904–1985)