S
S
SurelL2016-04-18 19:54:40
Programming
SurelL, 2016-04-18 19:54:40

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

3 answer(s)
A
Andrew, 2016-04-18
@OLS

It seems to me that codeforces provides adequate answers to this question (the first link in Yandex)

U
uvelichitel, 2016-04-18
@uvelichitel

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.

L
Lertmind, 2016-04-18
@Lertmind

The question was already on the toaster How to find the median of a one-dimensional array , come in handy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question