5
$\begingroup$

I have written an algorithm where the 2 input arguments are a file and a list of values. I would like to say the algorithm complexity is:

O(max{n,m}) where n is the size of the file and m is the length of the list

But maybe I'm mixing apples and oranges here. What is the correct way to write or express this?

$\endgroup$
4
$\begingroup$

Writing $O(m)+O(n)$ avoids the problem of having to address units. Note that $\max(m,n)$ and $m+n$ have the same order, and having max in a Landau symbol is quite uncommon.

$\endgroup$
  • 1
    $\begingroup$ The standard way to write it is just $O(m+n)$. Units can be safely ignored. $\endgroup$ – Geoffrey Irving Oct 15 '12 at 15:53

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.