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
  • 5,085
  • 9
  • 31
  • 45

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
  • 19,940
  • 10
  • 72
  • 93