Is $O(n \log n)$ always smaller than $O (m)$ for $n-1 < m < n^2$?

70 Views Asked by At

I am writing an algorithm that needs to finish in $O(m)$. The problem is for a graph $G( V, E )$, where $m = |E|$ and $n = |V|$. $m$ can be in the range of $n-1$ to $n^2 - 1$.

If I do some processing that takes $O\left( (n-3) \log(n-3)\right)$ time, will that still satisfy being smaller than $O(m)$ or not?

Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

$m > n - 1$ implies that $(n-3) \log(n-3) < (m-2) \log (m-2)$. That is $O(m \log m)$, but not $O(m)$.