Rotate Merge Sort

Rotate Merge Sort is a simple in-place Merge Sort that runs in $$O(n\log^2 n)$$ time which is far better than the naive methods that run in $$O(n^2)$$. Although there are multiple variants of Rotate Merge Sorts, they all work the same way in that they halve the merging recursively.



In general, a rotate merge halves the merge into subproblems of half the size in $$O(n)$$ time (rotation is $$O(n)$$). It continues to divide them into a constant length which is $$O(\log n)$$ partitions therefore the merge in a rotate merge is $$O(n\log n)$$. A Merge Sort merges a total of $$O(\log n)$$ layers therefore the total runtime of a Rotate Merge is $$O(n\log^2 n)$$.

$$\large T\left(n\right) = n\log n + 2T\left(\frac{n}{2}\right)= O(n\log^2 n)$$