2

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)$

lioness99a
  • 4,943
Digi1
  • 21
  • I don't know where you are trying to use this, but could you not introduce your own notation, such as $B=\max_n(A)$ to mean the $n$ biggest elements of $A$? – lioness99a Mar 27 '17 at 13:54
  • Thank you :). I think i can use this. I am using it in a pseudo code. – Digi1 Mar 27 '17 at 14:09

1 Answers1

0

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:]$

zwim
  • 28,563