Notation for selecting $n$ maximum entries of an array?

189 Views Asked by At

I have a vector $A=\left[\begin{array}{ccccc}1&2&5&4&3\end{array}\right]$ and I get vector $B=\left[\begin{array}{cc}4&5\end{array}\right]$, i.e., the maximum two elements of $A$.

What could be the proper notation for representing $B$? For example if I want to represent only the maximum value, I can write $B=\max(A)$

1

There are 1 best solutions below

0
On

Introducing a notation as lioness99a suggests is best, to suggest an array I think keeping the $[\cdot]$ notation is fine, so something like $\max[n](A)$.

Also if order has importance, for instance if you need $B=[4,5]$ rather than $B=[5,4]$ you have to define it explicitely.

Here is a possibility by induction:

$\begin{cases} \max[0](A)=[\ ] \\ \max[n+1](A)=[\max(A\setminus\max[n](A))]\oplus\max[n](A) \end{cases}$

Or something more direct:

$\max[n](A)=[m_n,m_{n-1},...,m_1]$ where $m_i=\max(A\setminus[m_{i+1},...,m_1])]$

Or even something python-like:

$\max[n](A)=\operatorname{IncreasingSort}(A)[-n:]$