reset password
Author Message
jpascua
Posts: 197
Posted 23:42 Oct 13, 2014 |

So I felt that I somewhat understood the exercises that were done as in a group last week. The thing is, what's the purpose? I felt that most of it was just math review.

This is what I understand so far: the running time of an algorithm is represented as a function f(n). Where n is the input size (though what we care about most are large input sizes). f(n) has an upper bound (big O) and a lower bound (big Omega?). I'm not quite sure what theta is here. 

From the exercises, if f(n) = O(g(n)) and f(n) = Ω(g(n)) then f(n) = Ɵ(g(n)). But what is this g(n)? Aren't we focusing only on one function f(n) which is the running time of the algorithm?

I might be looking at it weirdly. Sometimes notation can be pretty confusing to me.

G190852562
Posts: 162
Posted 00:56 Oct 14, 2014 |

I think you were warned ahead of time that this was a more mathy course than a programming course.

 

In case you missed that- Heads up: This course is going to be very math heavy course with a minimal amount of programming.

 

Now to answer your questions. The purpose of the exercise is to introduce us to algorithms and their analysis.Yes. Yes.  Big Theta is both big O and big Omega.  So while big-O is an upper bound and big Omega is a lower bound, big Theta is equality(asymptotic equality).  g(n) is some function that works to create bounds on how fast or slow f(n) grows.Yes, we care about f(n) which is how fast/slow an algorithm grows.  That's what g(n) is, it describes how fast/slow f(n) grows by putting a bound on it.

yxu22
Posts: 25
Posted 08:59 Oct 14, 2014 |

I can answer some of your questions.

1, What is the representation of running time and what is g(n)?

We use asymptotic notation to representation running time.

For example, f(n) is our code running time representation. And f(n) = O(g(n)). f(n) = Omega(h(n)).   O(g(n)) means f(n) grows less than the order of g(n).  Omega(h(n)) means f(n) grows greater than the order of g(n).

In this example, O(g(n)) is an upper bound of f(n) and Omega(h(n)) is a lower bound of f(n).

So if f = O(g), function g represents the worst case running time of f.

if f = Omega(h), function h represents the best case running time of f.

g(n) is another function that we used to describe the bound of f(n) ( or you can think that g(n) is a representation of the limits of f(n) )

The reason why we use g(n) is generally we don't care about the details of running time in f(n) . We only want to know the growth order. Then we can use a simple function such as g(n) to compare different algorithm.

 

2. Theta notation 

f = Theta(g) means f grows as same as g. So if f = Theta(g) , we can use the simple function g to represent the running time, too (running time of both best case and worst case could be g).

Theta Definition 

/***Def: Let g be a function with domain the nonnegative integers and range the positive real numbers. 

Theta(g) is the set of all functions f, such that for some real constants c1 > 0 , c2 > 0 and some nonnegative integer constant n0,

c1 * (g(n)) <= f(n) <= c2 * g(n) for all n >= n0  ***/

Theta(g) = { f: exist c1 > 0 , exist c2 > 0, exist n0 >= 0 , such that c1 * (g(n)) <= f(n) <= c2 * g(n) for all n >= n0 }

One property of Theta notation :

f(n) = Theta(g(n))  <=>  { f(n) = O(g(n)) and f(n) = Omega(g(n)) }

 

PS: Algorithm course is a theory course to learn some classic computational problems such as sorting, ranking, find same sequence, find graph path and so on, how to solve them in pesudo code and how to analysis your code. 

Last edited by yxu22 at 09:28 Oct 14, 2014.
rabbott
Posts: 1649
Posted 10:53 Oct 14, 2014 |

Thank you YXU22 and AnonCS312 for those good answers!

If you have additional questions or if it's still not clear, please post again.

Last edited by rabbott at 10:54 Oct 14, 2014.