Big O Example – Graph

Hi everyone. I see that many of you have submitted your Test #1 review exercises and are making corrections already…that’s great! I’ll take a look at them tomorrow after class. Don’t forget to tag your post with the category “Test #1 Review” on the right side of the screen.

In the meantime…some of you are still having trouble understanding Big O notation. I can’t stress enough how important the definition on page 205 is. It’ll be impossible to understand what calculations to perform without at least an understanding of the definition. We discussed the way to think about it graphically in class and during office hours, and I just wanted to share an example here.

You can use this graph to see why f(x)=x^2+x+1 is O(x^2). Remember that the definition says that there must exist a pair of positive constants (C,k) so that whenever x>k, the inequality |f(x)| \leq C|g(x)| is satisfied. On the graph in the link, you get to play with the slider tools on the left side of the screen to change the values of C and k. Your goal is to find a pair (C,k) so that whenever a point is in the green region, the red graph is below the blue graph. (In this case, since all y-values are non-negative, you can add the absolute value bars without changing anything.)

You’ll see that there will be very many possible choices for (C,k). If you were proving that f(x)=x^2+x+1 is O(x^2) by hand, you might find one particular choice is easiest to work with. Because the definition involves an existence statement, you just need to find one pair (C,k) that works.

Hope this helps!

This entry was posted in Discussion. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *