Median of Medians in Java

前端 未结 5 1501
清歌不尽
清歌不尽 2020-12-03 09:11

I am trying to implement Median of Medians in Java for a method like this:

Select(Comparable[] list, int pos, int colSize, int colMed)
5条回答
  •  一整个雨季
    2020-12-03 10:02

    I know it's a very old post and you might not remember about it any more. But I wonder did you measure the running time of your implementation when you implemented it?

    I tried this algorithm and compare it with the simple approach using java sorting method (Arrays.sort() ), then pick the kth element from sorted array. The result that I received is that this algorithm only out-beat java sorting algorithm when the size of the array is about hundred thousand elements or more. And it's only about 2 or 3 times faster, which is obviously not log(n) time faster.

    Do you have any comment on that?

提交回复
热议问题