What is an easy way for finding C and N when proving the Big-Oh of an Algorithm?

前端 未结 5 903
故里飘歌
故里飘歌 2020-12-24 09:14

I\'m starting to learn about Big-Oh notation.

What is an easy way for finding C and N0 for a given function?

Say, for example:

(n+1)5

5条回答
  •  时光取名叫无心
    2020-12-24 09:32

    Usually the proof is done without picking concrete C and N0. Instead of proving f(n) < C * g(n) you prove that f(n) / g(n) < C.

    For example, to prove n3 + n is O(n3) you do the following:

    (n3 + n) / n3 = 1 + (n / n3) = 1 + (1 / n2) < 2 for any n >= 1. Here you can pick any C >= 2 with N0 = 1.

提交回复
热议问题