How to sort in-place using the merge sort algorithm?

前端 未结 10 1592
心在旅途
心在旅途 2020-11-22 02:21

I know the question is not too specific.

All I want is someone to tell me how to convert a normal merge sort into an in-place merge sort (or a merge sort with const

10条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 03:08

    Just for reference, here is a nice implementation of a stable in-place merge sort. Complicated, but not too bad.

    I ended up implementing both a stable in-place merge sort and a stable in-place quicksort in Java. Please note the complexity is O(n (log n)^2)

提交回复
热议问题