2
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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$? $\endgroup$ – lioness99a Mar 27 '17 at 13:54
  • $\begingroup$ Thank you :). I think i can use this. I am using it in a pseudo code. $\endgroup$ – Digi1 Mar 27 '17 at 14:09
0
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.