Finding the median of an unsorted array

后端 未结 8 1128
后悔当初
后悔当初 2020-11-28 05:01

To find the median of an unsorted array, we can make a min-heap in O(nlogn) time for n elements, and then we can extract one by one n/2 elements to get the median. But this

8条回答
  •  广开言路
    2020-11-28 05:35

    You can use the Median of Medians algorithm to find median of an unsorted array in linear time.

提交回复
热议问题