Assuming that big-O notation is used in the sense of asymptotic tight bound
, which really should be denoted with a big-Theta, then I would answer C), because Theta(n) = Theta(n + log(n))
. (Because log(n)
is dominated by n
).
If I am formally (mathematically) correct, then I would say that none of these answers is correct, because O(n)
and O(n+log(n))
only give upper bounds, but not lower bounds on the asymptotic behaviour:
Let f(n) in O(n)
and g(n) in O(n + log(n))
. Then there are the following contra examples:
For A): Let f(n) = n
in O(n)
and g(n) = 1
in O(n + log(n))
. Then g(n)
does not dominate f(n)
.
for B): Let f(n) = 1
in O(n)
and g(n) = n
in O(n + log(n))
. Then f(n)
does not dominate g(n)
.
for C): Let f(n) = 1
in O(n)
and g(n) = n
in O(n + log(n))
. Then g(n)
does dominate f(n)
.
As this would be a very tricky question, I assume that you use the more common sloppy definition, which would give the answer C). (But you might want to check your definitions for big-O
).
If my answer confuses you, then you probably didn't use the formal definition and you should probably ignore my answer...