Notation for the "k" largest elements of array

146 Views Asked by At

Introduction. Given a set, or a vector, or a sequence $A$ with components: \begin{equation} A = \{a_1, a_2, a_3, \ldots, a_n \} \end{equation} we can indicate the maximum of $A$ as $\max(A)$, or as $\max(\{a_1, a_2, a_3, \ldots, a_n \})$.

Question. Is there any specific notation to indicate the "k" top maxima (i.e. the "k" largest values)? I mean, if we sort an array in a descending order, i.e. from the largest to the smallest values, is there a notation to say "we consider the "k" top largest values"?

Note. I would like to mathematically (and correctly) write what some programming languages do, such as, for example, the Matlab "maxk" function.

2

There are 2 best solutions below

2
On BEST ANSWER

Use the concept of sorting, and address the $(n-k+1)$ element:

Let A be a sorted sequence of numbers, denoted by

$A = \{a_1, a_2, a_3, \ldots, a_n\}$

such that $ a_i<a_j$ for all $i<j$

If you cannot define $A$ as a sorted sequence, then define another sequence $SA$ which is a sorted sequence of the elements of $A$. This can be done using the following definition:

$SA = \text{sort}(A)$

The $k^{th}$ largest element is $SA_{n-k+1}$, or if $A$ is sorted, then his $k^{th}$ largest element is $A_{n-k+1}$

2
On

I would simply write something as follows.

Let $A = \{a_1, a_2, a_3, \ldots, a_n \}$, where $a_1 > a_2 > \cdots > a_n$.
Now, assume $k < n$ so that we define $\max_{k}:=\{a_1, a_2, \dots, a_k\}$
(i.e., $\max_{k} \subset A$ since $A - \max_{k} = \{a_{k+1}, a_{k+2}, \dots, a_{n-1}, a_{n}\}$).

I think it should work fine.