6

According to the lecture note by Jeff Erickson, the lower bound for finding the third largest element of a set of $n$ distinct elements is open. See the related post: What is the lower bound for finding the third largest in a set of $n$ distinct elements?

Given that the tight lower bound is still unknown, I want to know the algorithms currently published in papers (meaning that they are not trivial, for example, by finding and removing the largest and the second largest elements and finding the third largest one in $(n-1) + (n-2) + (n-3) = 3n - 6$ time) for finding the third largest element.

Searching for "algorithm finding the third largest element" in Google does not bring me useful references.

hengxin
  • 9,671
  • 3
  • 37
  • 75

1 Answers1

7

For $n>5$, this paper proves that the number of comparisons deterministic algorithms need is ​$n ​ + ​ \big(2 \cdot \lfloor \log_{2}(n)\rfloor \big) ​- ​\big(\text{an element of } \{1,2,3\}\big)$, where that element depends on $n$'s position relative to the nearby powers of $2$.

Furthermore, for $n>7$, that paper gives a deterministic algorithm which achieves those values.

By pages 330 and 331, the average number of comparisons needed is ​ $n + \Theta(\ln\ln n)$.

Theorem 5 is that the average number of comparisons used by that paper's algorithm is at most ​$n + 5 ​\cdot ( 11 + \ln\ln n)$. I have currently not located anything else regarding non-worst-case algorithms for your problem, although I've kept finding more as I go along.

David Richerby
  • 82,470
  • 26
  • 145
  • 239