Nearly-optimal mergesort: Fast, practical sorting methods that optimally adapt to existing runs
Mergesort can make use of existing order in the input by picking up existing runs, i.e., sorted segments. Since the lengths of these runs can be arbitrary, simply merging them as they arrive can be wasteful—merging can degenerate to inserting a single elements into long run.
In this talk, I show that we can find an optimal merging order (up to lower order terms of costs) with negligible overhead and thereby get the same worst-case guarantee as for standard mergesort (up to lower order terms), while exploiting existing runs if present. I present two new mergesort variants, peeksort and powersort, that are simple, stable, optimally adaptive and fast in practice (never slower than standard mergesort and Timsort, but significantly faster on certain inputs).
I gave this talk at ESA 2018 and it is based on joint work with Ian Munro. The paper and further information can be found on my website:
https://www.wild-inter.net/publications/munro-wild-2018