Asked By : chopper draw lion4
Answered By : Guildenstern
Let $f$ and $g$ be two functions defined on some subset of the real numbers. One writes $f(x) = O(g(x))$ as $x to infty$, if and only if there is a positive constant $M$ such that for all sufficiently large values of $x$, $f(x)$ is at most $M$ multiplied by the absolute value of $g(x)$. That is, $f(x) = O(g(x))$ if and only if there exists a positive real number $M$ and a real number $x_0$ such that $|f(x)| leq M cdot |g(x)|$ for all $x geq x_0$.
We see that $f$ and $g$ are functions. Together with all the variables used, and the relations between them, what $f(x) = O(g(x))$ means is as clear as you might reasonably expect from a Wikipedia article on a mathematical topic. We don’t have to consider what this notation is supposed to be used for, and neither what those functions are even supposed to represent/model. Now, going back to the application domain of algorithm analysis; can we use this notation to describe algorithms? Yes, since runtimes of algorithms are just functions on real numbers. Then what does it mean when $f(x) = O(g(x))$, in the context of algorithm analysis? If $f(x)$ is the runtime of the algorithm, then this notation means that $f(x)$ (a runtime) does not grow more quickly than a multiple of $g(x)$, for sufficiently large $x$. That’s all from reading from the definition, and interpreting $f(x)$ as a runtime.
Pitfalls of convention
Sometimes, conventions can be misleading. In fact, we’ve seen a “violation” of a usual mathematical convention in this post. $f(x) = O(g(n))$ Here, the $=$ sign is used. At least for us non-mathematicians, we are used to this sign denoting a sort of equality between two things. This usually means that the two things are of the same type, e.g. they are both real numbers, and that they are equal in some sense. In particular, $=$ is often an equivalence relation. But this is not the case of this particular use of the $=$ sign. First of all, $f(x) = O(g(n))$ does not mean that $f(x)$ and $g(x)$ are equal: the closest “normal” relation to this is “$f(x)$ is less than or equal to $g(x)$”, which obviously has nothing to do with equality (except as a special case). Secondly, $f(x)$ and $O(g(x))$ are not even of the same type: $f(x)$ is a function, while $O(g(x))$ is a class of functions. (An alternative notation to $f(x) = O(g(x))$ is $f(x) in O(g(x))$, which I used in the beginning. It is arguably more “honest”.)
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/30588