fourthlargest
Fourthlargest is a term used to describe the element that ranks fourth when a collection of values is ordered from largest to smallest. In practice, there are two common interpretations of what counts as the “fourth largest,” depending on whether duplicates are treated as separate items or as a single distinct value.
If duplicates are counted (the standard interpretation in many programming problems), the fourth largest is the
Computing the fourth largest can be done in several ways. A straightforward method is to sort the
Example: with the numbers [9, 7, 9, 5, 3, 7, 4], the fourth largest including duplicates is
See also k-th largest element, order statistics, and Quickselect.