Answer the question
In order to leave comments, you need to log in
What are the algorithms for finding the median of a one-dimensional array without using sorting?
Let's say we have a one-dimensional array. What are the algorithms for finding its median without using sorting (for example, bubble sort)?
Answer the question
In order to leave comments, you need to log in
It seems to me that codeforces provides adequate answers to this question (the first link in Yandex)
Do quicksort, but at the recursive step, sort not both received wings, but only the one that is closer to the median. For example, if the first round of quicksort split the array into parts of 50 and 70 elements, then on the second round, sort only a part of 70. Let's get 30 and 40, then the median in part 30 is to sort it. So until victory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question