Search code examples
big-oanalysisasymptotic-complexityproof

Prove max(O(f(n)), O(g(n)))=O(max(f(n), g(n))


Prove max(O(f(n)), O(g(n)))=O(max(f(n), g(n))

It does make sense, but so far I don't have any idea how to actually prove it.

Any input would be appreciated.


Solution

  • f(n) <= max(f(n), g(n))
    g(n) <= max(f(n), g(n))
    
    max(O(f(n)), O(g(n))) <= O(max(f(n), g(n)), max(f(n), g(n))) = O(max(f(n), g(n)))
    

    Note that the in-equalities used are not strict.