Search code examples
big-oasymptotic-complexity

Algorithm domination


Studying for a test and getting this question:

Comparing two algorithms with asymptotic complexities O(n) and O(n + log(n)), 
which one of the following is true?

A) O(n + log(n)) dominates O(n)
B) O(n) dominates O(n + log(n))
C) Neither algorithm dominates the other.

O(n) dominates log(n) correct? So in this do we just take o(n) from both and deduce neither dominate?


Solution

  • Yes, that's correct. If runtime is the sum of several runtimes, by order of magnitude, the largest order of magnitude dominates.