Median

C

CBFalconer

Marcin said:
How I can find median (middle element) in T(n) = O(n) int the
worst case?

By asking in a newsgroup where it is topical, such as
comp.programming. You probably won't like the answer.
 
B

BGreene

Marcin said:
How I can find median (middle element) in T(n) = O(n) int the worst case?
This depends on what O(n) means, comparisons, moves, passes over the data
etc...

I think you are impying comparisons, in which case it cannot be done.
 
R

Richard Harter

This depends on what O(n) means, comparisons, moves, passes over the data
etc...

I think you are impying comparisons, in which case it cannot be done.

As it happens the subject is off topic and your reply is incorrect;
the median can be found using worst case O(n) comparisons.



Richard Harter, (e-mail address removed)
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
 
D

Daniel Etzold

Richard said:
As it happens the subject is off topic and your reply is incorrect;
the median can be found using worst case O(n) comparisons.

btw, each deterministic algorithm requires at least 2n
comparisons in worst case to find the median (currently the best known
requires det. alg. requires about 2.95n comparisons).
A very simple randomized algorithm finds the median with at most
1.5n + o(n) comparisons with prob. 1-n^(1/4).

Regards,
Daniel
 
B

BGreene

I apologize for this ignorant post. I was thinking n comparsions not O(n).
Next time I'll keep my keyboard quiet :).

Barry
 
P

pete

BGreene said:
I apologize for this ignorant post.
I was thinking n comparsions not O(n).
Next time I'll keep my keyboard quiet :).

Big O refers to the dominant term
of the equation which governs the running time.
 
R

Richard Harter

I apologize for this ignorant post. I was thinking n comparsions not O(n).
Next time I'll keep my keyboard quiet :).

No problem. It's not at all obvious (until you think of the trick)
that it can be done in guaranteed O(n) comparisons. The best
published algorithms involve dancing widdershins and flapping your
arms chicken style.


Richard Harter, (e-mail address removed)
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top