# Formula for 6th largest value in a set of 10

#### jollywg

Hello,

I have a math problem that I am trying to solve within the limitations of a piece of software that I use at work.

I have ten places where I take measurements on a item. I need to find the 6th largest value of the ten. Normally I would sort the values descending and select the 6th one. But the software does not have a sort function.

It has the ability to use IF/THEN logic and a lot of basic math functions and several trig functions.

I would like some help in figuring out this 6th largest value mathematically.

Thanks
jollywg

#### Bacterius

Hello,

I have a math problem that I am trying to solve within the limitations of a piece of software that I use at work.

I have ten places where I take measurements on a item. I need to find the 6th largest value of the ten. Normally I would sort the values descending and select the 6th one. But the software does not have a sort function.

It has the ability to use IF/THEN logic and a lot of basic math functions and several trig functions.

I would like some help in figuring out this 6th largest value mathematically.

Thanks
jollywg
Hello, you know you got a brain, too ? (Don't get me wrong, but a 10-value set is easily inspected, not like a 20-million set) Anyway, there is no "mathematical" formula that takes a set as an input and outputs the greatest value of the set. You can only use an algorithm that is formally defined by a series of well-defined steps.

Here is the naïve algorithm :

(1) Take the first two values : put the greatest in memory.
(2) Take the next value and the value in memory. If the next value is greater than the one in memory, replace the memory value with the next value, otherwise proceed.
(3) Repeat (2) until you reach the last value.
(4) The last value is the greatest integer in the set.

Takes a lot of time for big sets. The other algorithms run a lot faster and are not that complicated (take values by pairs, halving the number of values each step, take them by triplets, dividing the number of values by 3 at each step). Variations of this algorithm return the 2nd, 3rd, 4th greatest value in the same time.
_________________

If your piece of software does not support sequential execution of code, then it is not possible to write a single formula that gives the greatest value of a set. Why don't you download GCC and write a quick 5-line program using the algorithm described here (or the improved one) ? It's free, and can solve absolutely any problem because it is Turing-complete (unlike your maths software)

#### jollywg

Thanks for the information.