0

Possible Duplicate:
How to calculate or approximate the median of a list without storing the list

I want to apply using C# an algorithm to find the median value using selection/quick sort. But I do not want to sort the whole array in order to get the median.

Can I do it?

Community
  • 1
  • 1
Mohamad Ibrahim
  • 3,345
  • 7
  • 26
  • 41

1 Answers1

1

Wikipedia's entry on Selection Algorithm gives various alternatives, including the Median of Medians approach, which would seem to fit your requirements. In particular, it has a worst-case performance of O(n).

Matthew Strawbridge
  • 18,016
  • 10
  • 65
  • 86