I'm working on a quicksort class, but I'm required to get the pivot multiple ways (last value, median of 3, and median of 5). Getting the median of 3 is easy enough with a few if statements, but I'm having trouble figuring out how to get a median of 5 in the most efficient manner. We're timing the quicksort, so the more efficient the method of finding the median of 5, the better.
I've looked around quite a bit, and many of the ways of doing this involves sorting the array first, which is not what I want it to do. Any ideas of how to do this?
P.S. I'm not necessarily asking for code, although it would be useful. Just a proper approach would be fine.