Mergesort is simple, simple, efficient, and stable: splits a list, sorts recursively, and combines results.
To be more specific, mergesort accepts O (N log N), which is asymptotically optimal. In addition, in practice (using both algorithms modified to sort short sublists with a special type), mergesort can be a close competitor to the modified quick sort used in standard C / C ++ libraries.
Edit: unlike in-place sorts, such as quicksort and insertion sorting, mergesort requires auxiliary memory and is easiest to implement by copying rather than swapping.
source
share