Which one is asymptotically larger? $100n+\log n$ Or $n+(\log n)^2$

2.7k Views Asked by At

In the book Algorithms by Sanjoy Dasgupta in 1st chapter exercise

Q.1. In each of the following situation, indicate whether $f = \mathcal{O}(g)$ , or $f = \Omega(g) $, or both (in which case $ f = \Theta(g) $

(c) $f(n) = 100 n + \log\,n $ , $g(n) = n + (\log\, n)^2$

I have plotted it in Desmos. I have no idea why $f(n)$ is growing faster even though $g(n)$ has square in it. I might be wrong. Please explain which one is larger and why?

1

There are 1 best solutions below

0
On BEST ANSWER

Hint: $f(n)$ is $\mathcal O(g(n))$ if $\exists c\ge0$ s.t. $\displaystyle\lim_{n\to\infty}\dfrac{f(n)}{g(n)} = c$.

From Wolfram Alpha, $\displaystyle\lim_{n\to\infty}\dfrac{f(n)}{g(n)} = \lim_{n\to\infty}\dfrac{100n + \log n}{n + \log^2n} = 100$. Therefore, $f(n)$ is $\mathcal O(g(n))$.

As a practice, try to solve the limit (using L'Hospital's Rule) yourself and see whether the limit does, in fact, result in a constant.

Also, this might be helpful.