-1

I'm beginning to study algorithmic stuff, and I'm confused about the notation O(n + m). I've seen some people take that to mean it's the maximum between 'n' and 'm', so O(max(n,m)) and others who read it literally. So if p = n + m, it'd be like saying O(p).

Which one is correct? Does it vary or is it standardized rule when talking about algorithms? Thanks!

John Doe
  • 113
  • 2
  • 7

1 Answers1

1

As Dukeling correctly pointed out, the two notations are equal, however sometimes it will be more intuitive and (may) convey more information to use the notation O(n+m).

iiirxs
  • 4,493
  • 2
  • 20
  • 35
  • 1
    "if n >> m then you could say that O(n+m) = O(n) as an approximation" - it's not an approximation, [they are equal](https://stackoverflow.com/questions/40366904/comparing-complexity-of-onm-and-omaxn-m). – Bernhard Barker Sep 05 '18 at 00:06