How can I express the formula (logn + 2)*(n - 1) using big-O notation
My try:-
(logn + 2)*(n - 1) => nlogn + 2n - logn - 2.
Now I am confused whether this is O(n) or O(log n)
How can I express the formula (logn + 2)*(n - 1) using big-O notation
My try:-
(logn + 2)*(n - 1) => nlogn + 2n - logn - 2.
Now I am confused whether this is O(n) or O(log n)
In fact, since $$ (\log n + 2)(n-1) = n\log n - \log n + 2n -2 $$ for all $n \geq 1$, neither dividing by $\log n$ nor by $n$ suffices to ensure boundedness; dividing by $n\log n$ suffices. So $(\log n+ 2)(n-1) = O(n\log n)$ as $n \to \infty$.