Big Oh Notation - formal definition

后端 未结 5 1507
耶瑟儿~
耶瑟儿~ 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:19

    Probably the reason that they said 50n<=50n^2 for n>=50 is that if n is less than 1, than n^2 < n. Of course, if n is a positive integer, then yes 50n<=50n^2. In this case, it seems that n is assumed to be a positive integer, although the formal definition they give doesn't state that explicitly.

    I can see why saying 50n<=50n^2 for n>=50 may seem a little silly. But it's still true. The book doesn't say 50n<=50n^2 holds ONLY for n>=50; that would be false.

    As an analogy, if I say "all of my siblings speak English", that would be true, even though there are a lot of people who speak English who are not my siblings.

    Regarding the proof, we might split it into different statements.

     (1): 4n^2 + 50n - 10 <= 4n^2 + 50n  (for all n)
     (2): 4n^2 + 50n <= 4n^2 + 50n^2 (for all n>=50)  
     (3): 4n^2 + 50n^2 = 54 n^2 (for all n, including all n>=50)
     (4): Therefore, 4n^2 + 50n - 10 <= 54n^2 for all n>=50
     (5): Therefore, for f(n)=4n^2 + 50n - 10, g(n)=n^2, N=50, and c=54, 
               the statement  f(n) <= c g(n) for all n >= N is true
     (6): Therefore, by definition 4n^2 + 50n - 10=O(n^2). 
    

    It should be clear that each of these statements is true, either on its own (1,2,3), or as a result of the previous statements.

提交回复
热议问题