Tuesday, December 2, 2014

Week 11 - Big-Theta and General Properties of Asymptotic Notation


So I heard from my CSC148 course that when computer scientists say a program runs in big-O of some function of n they generally mean that it is also in big- Θ of that function. My question is once we realize a program runs in say O(n2), do we even bother trying to show that it is also bounded above by n3 or bounded below by n when we can make that assessment by inspection? In other words, in practice do we typically worry about the other functions not in the same class or do we just prove that it is in big-O of something and leave it at that, until we can improve upon it.

I assume this is where the general properties for asymptotic notation come into play. Such as adding, and squaring a given function etc. and how they affect its relationship to its other bounds.  Thus we can very quickly say based on these properties that it performs better or worse than some other class of function without having to delve to much into the gritty details.

We had a similar question on Assignment 3 that resembles the concept of big-Θ. It asked us to show that there exists functions that do not bound each other above or below. And some people were suggesting that trigonometric functions such as sin(n) and cos(n) might work.  After thinking about that I came up with two flaws with using these functions.  Both sin(n) and cos(n) are functions that have a range in both the positive and negative reals. Thus these two functions violate the requirement that f(n) must only map onto 0 or the positive reals.  To prevent this, we could add a constant to raise the entire function above the x-axis but then why not just use a horizontal line?  Moreover, once you raise one trigonometric function entirely above the x-axis it then does behave like a horizontal line in that you can multiply it by some constant to bound the other trigonometric function above and below.  I went with a piecewise function, but even then the proof had many cases to show. Hopefully I caught them all.

 On a side note I was roaming around on some of the other slogs and stumbled upon this cool python implementation for the folding paper problem. This student also implemented something in graphical form which I thought was nice.
http://courseblog165.blogspot.ca/

Oh by they way, you can also run the code for my penny piles problem in the interpreter. Its kind of fun to find combinations of inputs that have really long sequences. Its been a while but I think (8, 99) and (16, 99) produce some neat outputs.  If you are really brave you can try (32, 9999)!

No comments:

Post a Comment