How do I get c = 4 and n0 = 21, I understand that I could plug in different numbers till f(n) ≤ c * n for all n ≥ n0, but using f(n) how do I arrive at those numbers?
3n^3 + 20n^2 + 5
3n^3 + 20n^2 + 5 is O(n^3)
need c > 0 and n0 ≥ 1 such that 3n^3 + 20n^2 + 5 ≤ c*n^3 for n ≥ n0
this is true for c = 4 and n0 = 21
I'm also struglling to get my head around this one,
3 log n + 5
3 log n + 5 is O(log n)
need c > 0 and n0 ≥ 1 such that 3 log n + 5 ≤ c*log n for n ≥ n0
this is true for c = 8 and n0 = 2
We first show how to obtain the numbers mentioned for $3n^3+20n^2+5$. If $n\ge 2$, then $20n^2+5\le 21n^2$. And if $n\ge 21$ then $21n^2\le n^3$. So if $n\ge 21$ then $3n^3+21n^2+5\le 4n^3$.
Remark: I would not have shown that $3n^3+20n^2+5$ is $O(n^3)$ in this way. Here is an alternative less thinking way. If $n\ge 1$ then $20n^2\le 20n^3$ and $5\le 5n^3$. It follows that if $n\ge 1$ then $3n^3+20n^2+5\le 3n^3+20n^3+5n^3=28n^3$. A much cruder upper bound, but it does the job!
For $3\log n +5$, I will assume that since this seems to be from a discrete math for Computer Science course, the logarithm is to the base $2$. If $n\ge 32$ then $\log n\ge 5$. It follows that if $n\ge 32$ then $3\log n+5\le 4\log n$. If another $\log$ is intended, for example $e$, then $32$ can be replaced by any integer greater than $e^5$.