Finding largest and second-largest out of N numbers
问题 Given n numbers, how do I find the largest and second largest number using at most n+log(n) comparisons? Note that it's not O(n+log(n)), but really n+log(n) comparisons. 回答1: pajton gave a comment. Let me elaborate. As pajton said, this can be done by tournament selection. Think of this as a knock out singles tennis tournament, where player abilities have a strict order and the outcome of a match is decided solely by that order. In the first round half the people are eliminated. In the next