given 5 numbers, what is the minimum number of comparisons needed to find the median?
how do you setup minimum number of comparisons in general? James McNellis To cite Donald Knuth (by way of Wikipedia, since I don't have my copy of TAOCP at the moment), the lower bound for the number of comparisons is six: http://en.wikipedia.org/wiki/Selection_algorithm (scroll down to the section entitled "Lower Bounds"). Your goal is, effectively, to find the k lowest values where k is half the size of the list, rounded up, (so, k = 3; n = 5) and then take the max of those. Plugging that into the formula there on the page, you get: (5 - 3) + 1 + 1 + 2 = 6 In this case, the actual minimum