Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

problem on medians


What are the least no. of comparisons required to find the median of a
set of n integers ?
Which is the best algorithm for this?

PS: not a homework question!

Ajinkya

What are the least no. of comparisons required to find the median of a
set of n integers ?
Which is the best algorithm for this?

PS: not a homework question!

Ajinkya

Ajinkya wrote:
> What are the least no. of comparisons required to find the median of a
> set of n integers ?
> Which is the best algorithm for this?

> PS: not a homework question!

Nor is it a C one!

Try somewhere like comp.programming.

--
Ian Collins.

"Ajinkya" <kaleajin@gmail.com> wrote in message

news:1180589789.498330.85780@i38g2000prf.googlegroups.com...
> What are the least no. of comparisons required to find the median of a
> set of n integers ?
> Which is the best algorithm for this?

> PS: not a homework question!

If it is not homework then copy the numbers to a temporary array, sort them
with qsort(), and take the middle.
There might be a cleverer way of doing it, but it is pointless in a
practical app.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

"Ajinkya" writes:
> What are the least no. of comparisons required to find the median of a
> set of n integers ?
> Which is the best algorithm for this?

> PS: not a homework question!

There is a book which specializes in such questions.  It is _Programming
Pearls_ by Bentley.  ISTR there is another volume, too, which is out of
print but the one above is probably sufficient.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc