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
You can use the Median of Medians algorithm to find median of an unsorted array in linear time.