2

I am given two functions: F1(n)=2n+20 and F2(n)=n+1. I have to show which one is better.

Our lecturer solved a similar problem. Given F1(n)=n2 and F2(n)=2n+20, he did:

F2(n)/F1(n)=(2/n)+(20/n2)

and he said it would be always less than 22, hence 2n+20 is better.

My doubt is how do I solve these types of comparison between functions. I have gone through all questions previously asked here and didn't quite understand it.

Also if given (an2+bn+c)=O(n2), please help in choosing constants c1, c2, n0 such that

c1g(n) ≤ f(n) ≤ c2g(n).

FatihAkici
  • 4,679
  • 2
  • 31
  • 48

1 Answers1

0

As stated in one of the comment, what a better complexity is first needs to be defined.

It is likely your lecturer means a complexity C(n) better than K(n) if and only if C(n) << K(n) (or using Landau notations C(n) = o(K(n))) as n -> +Inf.

If you want to compare two complexities F1(n) and F2(n), one method is to check if the quotient F2(n)/F1(n) converges and if so, to which value. With F2(n) ~ n and F1(n) ~ n^2, F2(n)/F1(n) converges towards 0 and therefore F1(n) dominates F2(n) towards infinity. You would say F1(n) is better given the language convention adopted earlier.

Note that "it (F2(n)/F1(n)) would be always less than 22 and told 2n+20 is better" is not a correct approach to asymptotic analysis in case of domination relationships (o(.) or equivalently <<)(I doubt your lecturer said that for the F1(n) and F2(n) defined above.).

In your last question - could you please define f(n) and g(n) ?

Alexandre Dupriez
  • 3,026
  • 20
  • 25