Some standard books on Algorithms produce this:
0 ≤ f(n) ≤ c⋅g(n) for all n > n0
While defining big-O, can anyone explain to me what this means, using a strong example which can help me to visualize and understand big-O more precisely?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assume you have a function
f(n)and you are trying to classify it – is it a big O of some other functiong(n).The definition basically says that
f(n)is inO(g(n))if there exists two constants C,N such thatNow, let’s understand what it means.
Start with the
n>Npart – it means, we do not “care” for low values ofn, we only care for high values, and if some (final number of) low values do not follow the criteria – we can silently ignore them by choosingNbigger then them.Have a look on the following example:
Though we can see that for low values of n:
n^2 < 10nlog(n), the second quickly catches up and afterN=10we get that for alln>10the claim10nlog(n) < n^2is correct, and thus10nlog(n)is inO(n^2).The constant
cmeans we can also tolerate some multiple by constant factor, and we can still accept it as desired behavior (useful for example to show that5*nisO(n), because without it we could never findNsuch that for eachn > N:5n < n, but with the constantc, we can use c=6 and show5n < 6nand get that5nis inO(n).