Big Oh Notation - formal definition

后端 未结 5 1512
耶瑟儿~
耶瑟儿~ 2020-12-19 05:39

I\'m reading a textbook right now for my Java III class. We\'re reading about Big-Oh and I\'m a little confused by its formal definition.

Formal Definition: \"A func

5条回答
  •  生来不讨喜
    2020-12-19 06:44

    Keep in mind that you're looking for "an upper bound on f(n) when n is sufficiently large." Thus, if you can show that f(n) is less than or equal to some cg(n) for values of n greater than N, this means cg(n) is an upper bound for f(n) and f(n)'s complexity is therefore O(g(n)).

    The examples given are intended to show that the given function f(n) can never grow beyond c*g(n) for any n > N. By manipulating an initial upper bound so it can be expressed more simply (if 4n^2 + 50n is an upper bound on f(n) then so is 4n^2 + 50n^2, which is equal to 54n^2, which becomes your 54*g(n) where c = 54 and g(n) = n^2), the authors can show that f(n) is bounded by c*g(n), which has complexity O(g(n)) and therefore so does f(n).

提交回复
热议问题