Asked • 06/19/19

Fastest way of finding the middle value of a triple?

Given is an array of three numeric values and I'd like to know the middle value of the three. The question is, what is the <i>fastest</i> way of finding the middle of the three? My approach is this kind of pattern - as there are three numbers there are six permutations: if (array[randomIndexA] >= array[randomIndexB] && array[randomIndexB] >= array[randomIndexC]) It would be really nice, if someone could help me out finding a <i>more elegant</i> and <i>faster</i> way of doing this.

1 Expert Answer


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.