Problem
Consider:
f(x) = log n + 3n
What is the big O notation of this function?
It is simply O(n)
.
When you have a composite of multiple parts in Big O notation which are added, you have to choose the biggest one. In this case it is O(3n)
, but there is no need to include constants inside parentheses, so we are left with O(n)
.