I came across this sentence in a book about algorithms:
O -notation expresses the upper bound of a function within a constant factor
What does it mean?
I came across this sentence in a book about algorithms:
O -notation expresses the upper bound of a function within a constant factor
What does it mean?
g(n) another function taking n as a parameter. e.g. g(n) = n; g(n)=nlogn etc.
f(n) = O(g(n))
then there exists constants c and k such that for all n >= k, f(n) <= c*g(n).
It means, that on a real line, there exists a number k for which there exists a constant c that for each n >= k, f(n) <= c*g(n).
Less formal (less true): f won't grow faster than c times g.
This is just an attempted English description of the mathematical definition of big-O notation. If we have that f(n) = O(g(n)), then there exists constants c and k such that for all n >= k, f(n) <= c*g(n).
I believe the constant factor is referring to c.
O -notation expresses
Big-O refers to a a way of describing...
the upper bound of a function
..a "worst case scenario" for how quickly a function can grow based on in its input...
within a constant factor".
..that only guarantees the estimate not diverge indefinitely (i.e., that there is some number k
such that, nomatter what input you enter, the actual function will not be k
times worse than the Big-O estimate)
Does that help?