-3

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?

jotik
  • 17,044
  • 13
  • 58
  • 123
  • 2
    Enter "big o notation" into google. Read everything you can find. If there's something you don't understand, ask questions. – gnasher729 Jun 21 '16 at 21:54

3 Answers3

1

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.

xenteros
  • 15,586
  • 12
  • 56
  • 91
0

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.

Alharithi
  • 39
  • 1
  • 4
  • I'm a little confused about what is g(n), c, and k? could you explain it? – Mohammed Ashour Jun 21 '16 at 23:04
  • @MohammedAshour f(n) is a function on some input n (usually, "Time it takes to run an algorithm" as a function of "Size of input".) So, for example, f(n) might be "Time it takes to determine if a number is in a sorted list of n numbers". g(n) is a (usually) simpler function we're comparing f(n) to, to evaluate its performance. The c and k stuff is a formal way of describing the relation: there exists c and k such that, once the input is greater than k, f(n) will always be less than c*g(n). – Edward Peters Jun 22 '16 at 15:07
0

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?

Edward Peters
  • 3,623
  • 2
  • 16
  • 39