Computer Science Canada

Big-O Notation exercises

Author:  hamid1455 [ Fri Mar 22, 2013 5:13 pm ]
Post subject:  Big-O Notation exercises

I got this free version of an Algorithms book from one of the professors who wrote it and am trying to learn Algorithms, so the first topic in the book is Big-O notation.

The first section has some exercises:

In each of following situations, indicate whether f = O(g) OR f = omega(g) OR both (in which case f = (/)(g)

f(n) g(n)
1) n - 100 n - 200


In the first question it has f(n) = n - 100 and g(n) = n - 200. I re-read the part explaining f = O(g) a few times over and am still unsure on how to proceed with this kind of question. This is not for homework/assignment, I'm doing this for fun. Thanks in advance.

Author:  jbking [ Fri Mar 22, 2013 5:24 pm ]
Post subject:  Re: Big-O Notation exercises

First step is to consider which complexity class f and g belong.

n-100 = omega(n) as for really big n, this becomes linear as the constant terms matters less and less.
n-200 = omega(n) for the same reason, thus both are in the omega(n) class.

The key is to visualize for really large n, which factors will be the most important. In both cases it is the linear term.

http://en.wikipedia.org/wiki/Big_O_notation may be useful for some background.


: