I'm trying to compare two functions, such as f(n)=n^n and g(n)=n^10^10. I'm unsure if f(n) is O(g(n)) or vise-vera where g(n) is O(f(n)). From my understanding, n^n can be worse than n! and although g(n) is being raised to a large constant, it can be bounded by f(n) if multiplied by a certain constant. I am new to this topic, how can you see if a run time function can be bound by another, such as these?
Asked
Active
Viewed 179 times
0
-
Welcome to [cs.SE]! Note that you can use LaTeX here to typeset mathematics in a more readable way. See here for a short introduction. – FrankW Sep 19 '14 at 05:27
1 Answers
1
If $$\limsup_{n \rightarrow \infty} \frac{g(n)}{f(n)} < \infty,$$ then we have that $g(n)$ is $O(f(n))$.
That is actually (almost) the definition of the big-O notation (modulo the $| \cdot |$ function that I left out for readability). You would prove that using your math knowledge. Note that if you can show that $$\lim_{n \rightarrow \infty} \frac{g(n)}{f(n)} < \infty,$$ for strictly increasing positive functions $g$ and $f$, this implies the satisfaction of the first equation. Analyzing the latter function should be part of most computer science curricula.

DCTLib
- 2,742
- 16
- 13
-
Hi @DCTLib. This question just got closed as duplicate of http://cs.stackexchange.com/questions/824/sorting-functions-by-asymptotic-growth . I think it would be worth it for you to move your answer to that question. It answers that question, and does so both well and succinctly. – Wandering Logic Sep 19 '14 at 15:27
-
@WanderingLogic It's also subsumed by other answers on the reference question, isn't it? – Raphael Sep 20 '14 at 17:09
-
@Raphael, yes. I feel that this answer would add value there because of the clear and succinct style in which it is written, not because the answers on the reference question are incorrect or missing any important details. – Wandering Logic Sep 20 '14 at 17:50