I'm trying to get down how to prove that something is $O(\cdots)$ or $\Theta(\cdots)$ but no matter what I look at, I don't get the reasoning as to how I can come to an answer.
So here's a couple of examples I've looked at:
Show that for any real constants $a$ and $b$, where $b > 0$, $(n+a)^b = \Theta(n^b)$
Show that $\log_2(n!) = O(n\log _2 (n))$
For 1 I understand that I have to show:
$$c_1 n^b \leq (n+a)^b \leq c_2 n^b$$
Do I just plug in random numbers until something works? That's what all the sites I've looked at seem to be doing, but that doesn't make sense.
For 2 I know that I have to show:
$$0 \leq \log_2(n!) \leq c(n\log_2(n))$$
Again, where do I even start? I can't wrap my head around any of this. :( Thanks for your help and patience.
Intuitively, the first is saying that as $n$ gets large, you don't care about adding or subtracting a constant to the base in $n^b$.
You don't plug in something random, you have to think about what you can prove. For the first, if you knew that $a$ is positive, you could use $c_1=1$ and argue that as $n \lt n+a, 1\cdot n^b \lt (n+a)^b$ This fails if $a \lt 0$, but decreasing $c_1$ a bit will make it OK with a bit more work. Remember that we are talking about asymptotic behavior when $n$ is large, so it doesn't have to be true for all $n$, just for $n$ large enough. So if we take $c_1=0.9^b$ and $a \ge 0$ we can say $0.9^bn^b \lt (n+a)^b$ If $a \lt 0,$ we require that $n \gt -10a$. Then $0.9^bn^b =(0.9n)^b \lt (n+a)^b$ and we have that side. For the left side, the challenging point is when $a \gt 0$. We take $c_2=2^b$ (anything greater than $1$ will work, with a change to the minimum $n$) and require that $n \gt a$ Then $(n+a)^b \lt (2n)^b = 2^nb^n$
For the second, the left side is obvious as $n! \ge 1$ To get the right side, you should argue from Stirling's approximation, which looks much like what you have.