Time complexity

f(n)=1+n+log2n.Time complexity of f(n) is
a)o(1)
b)o(n)
c)o(log2n)
d)o(nlog2n)
please assume wherever log2n,it means log n to the base 2
I think it is option d is correct.Is it right?

please help!
I'm not being pedantic.
Is that o() a little-o or a big-O ?
It significantly affects the answer here.
it is big-O(time complexity)
abc1 wrote:
it is big-O(time complexity)


Ah, you must be careful how you write the question! (d) would actually have been "true" and (a), (b), (c) false if it was little o(), but (d) is not the answer if it is BIG O().

Ask yourself (or try it out with a sequence of numbers 1, 10, 100, 1000, 10000, ...), which of
1
N
log(N)
grows fastest as N gets large. (It doesn't actually matter which base of logarithms you use.)

When they are ADDED then the dominant term for large N sets the time complexity.

Thank you
Not to be too pedantic, but f(n) is just a calculation in which n is a variable. The OP asked for the time complexity of f(n). Technically, the answer is that calculating f(n) is constant, so the time complexity is O(1).

The assumed starting point of this discussion is that f(n) is actually the calculation of time complexity of some functionality based on a size 'n'. The discussion has been centered around the value of f(x), not its time complexity. In this case, I agree with what @lastchance has stated. However, the wording of the question in the OP is poor.
Technically, the answer is that calculating f(n) is constant, so the time complexity is O(1).
Calculating the increment of an unbounded variable (n) doesn't take constant time.
Topic archived. No new replies allowed.