How to find Big O notation here.

501 Views Asked by At

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)

2

There are 2 best solutions below

0
On BEST ANSWER

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$.

0
On

$(logn + 2)*(n - 1)$ ==> $(n - 1)logn + 2n - 2$

if n >> 1, $(n - 1)logn$ is bigger than $2n - 2$, so $O(nlogn)$